Ejemplo n.º 1
0
  public void testAsBoolean() throws Exception {
    assertEquals(false, BooleanNode.FALSE.asBoolean());
    assertEquals(true, BooleanNode.TRUE.asBoolean());
    assertEquals(false, IntNode.valueOf(0).asBoolean());
    assertEquals(true, IntNode.valueOf(1).asBoolean());
    assertEquals(false, LongNode.valueOf(0).asBoolean());
    assertEquals(true, LongNode.valueOf(-34L).asBoolean());
    assertEquals(true, new TextNode("true").asBoolean());
    assertEquals(false, new TextNode("false").asBoolean());
    assertEquals(false, new TextNode("barf").asBoolean());
    assertEquals(true, new TextNode("barf").asBoolean(true));

    assertEquals(true, new POJONode(Boolean.TRUE).asBoolean());
  }
Ejemplo n.º 2
0
 public void testAsInt() throws Exception {
   assertEquals(9, IntNode.valueOf(9).asInt());
   assertEquals(7, LongNode.valueOf(7L).asInt());
   assertEquals(13, new TextNode("13").asInt());
   assertEquals(0, new TextNode("foobar").asInt());
   assertEquals(27, new TextNode("foobar").asInt(27));
   assertEquals(1, BooleanNode.TRUE.asInt());
 }