Package com.google.web.bindery.autobean.shared.impl.AutoBeanCodexImpl

Examples of com.google.web.bindery.autobean.shared.impl.AutoBeanCodexImpl.Coder


  /**
   * Extra tests in here due to potential to confuse {@code false} and
   * {@code null} values.
   */
  public void testSplittableListBoolean() {
    Coder boolCoder = AutoBeanCodexImpl.valueCoder(Boolean.class);
    Splittable s = StringQuoter.createIndexed();
    bool(false).assign(s, 0);
    assertFalse("0 should not be null", s.isNull(0));
    assertTrue("s[0] should be a boolean", s.get(0).isBoolean());
    assertFalse("s[0] should be false", s.get(0).asBoolean());
    assertNotNull("Null decode", ValueCodex.decode(Boolean.class, s.get(0)));
    Object decodedBoolean = boolCoder.decode(testState, s.get(0));
    assertNotNull("decode should not return null", decodedBoolean);
    assertFalse("decoded value should be false", (Boolean) decodedBoolean);

    bool(true).assign(s, 1);
    assertTrue("s[1] should be a boolean", s.get(1).isBoolean());
    assertTrue("s[1] should be true", s.get(1).asBoolean());
    assertTrue("boolCoder 1", (Boolean) boolCoder.decode(testState, s.get(1)));

    Splittable.NULL.assign(s, 2);
    assertTrue("3 should be null", s.isNull(3));
    assertEquals("payload", "[false,true,null]", s.getPayload());
    List<Boolean> boolList = new SplittableList<Boolean>(s, boolCoder, testState);
View Full Code Here


  /**
   * Extra tests in here due to potential to confuse 0 and {@code null} values.
   */
  public void testSplittableListNumbers() {
    Coder intCoder = AutoBeanCodexImpl.valueCoder(Integer.class);
    Coder doubleCoder = AutoBeanCodexImpl.valueCoder(Double.class);
    Splittable s = StringQuoter.createIndexed();
    number(0).assign(s, 0);
    assertFalse("0 should not be null", s.isNull(0));
    assertTrue("s[0] should be a number", s.get(0).isNumber());
    assertNotNull("Null decode", ValueCodex.decode(Integer.class, s.get(0)));
    Object decodedInt = intCoder.decode(testState, s.get(0));
    assertNotNull("decode should not return null", decodedInt);
    assertEquals("intCoder 0", Integer.valueOf(0), decodedInt);
    assertEquals("doubleCoder 0", Double.valueOf(0), doubleCoder.decode(testState, s.get(0)));

    number(3.141592).assign(s, 1);
    assertEquals("intCoder 1", Integer.valueOf(3), intCoder.decode(testState, s.get(1)));
    assertEquals("doubleCoder 1", Double.valueOf(3.141592), doubleCoder.decode(testState, s.get(1)));

    number(42).assign(s, 2);
    Splittable.NULL.assign(s, 3);
    assertTrue("3 should be null", s.isNull(3));
    assertEquals("payload", "[0,3.141592,42,null]", s.getPayload());
View Full Code Here

TOP

Related Classes of com.google.web.bindery.autobean.shared.impl.AutoBeanCodexImpl.Coder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.