1 package com.fasterxml.jackson.databind.node; 2 3 public class TextNodeTest extends NodeTestBase 4 { testText()5 public void testText() 6 { 7 assertNull(TextNode.valueOf(null)); 8 TextNode empty = TextNode.valueOf(""); 9 assertStandardEquals(empty); 10 assertSame(TextNode.EMPTY_STRING_NODE, empty); 11 12 assertEquals(0, empty.size()); 13 assertTrue(empty.isEmpty()); 14 15 assertNodeNumbers(TextNode.valueOf("-3"), -3, -3.0); 16 assertNodeNumbers(TextNode.valueOf("17.75"), 17, 17.75); 17 18 long value = 127353264013893L; 19 TextNode n = TextNode.valueOf(String.valueOf(value)); 20 assertEquals(value, n.asLong()); 21 22 // and then with non-numeric input 23 n = TextNode.valueOf("foobar"); 24 assertNodeNumbersForNonNumeric(n); 25 26 assertEquals("foobar", n.asText("barf")); 27 assertEquals("", empty.asText("xyz")); 28 29 assertTrue(TextNode.valueOf("true").asBoolean(true)); 30 assertTrue(TextNode.valueOf("true").asBoolean(false)); 31 assertFalse(TextNode.valueOf("false").asBoolean(true)); 32 assertFalse(TextNode.valueOf("false").asBoolean(false)); 33 } 34 } 35