1 package com.fasterxml.jackson.databind.node; 2 3 import com.fasterxml.jackson.databind.JsonNode; 4 5 import com.fasterxml.jackson.databind.BaseMapTest; 6 7 abstract class NodeTestBase extends BaseMapTest 8 { assertNodeNumbersForNonNumeric(JsonNode n)9 protected void assertNodeNumbersForNonNumeric(JsonNode n) 10 { 11 assertFalse(n.isNumber()); 12 assertEquals(0, n.asInt()); 13 assertEquals(-42, n.asInt(-42)); 14 assertEquals(0, n.asLong()); 15 assertEquals(12345678901L, n.asLong(12345678901L)); 16 assertEquals(0.0, n.asDouble()); 17 assertEquals(-19.25, n.asDouble(-19.25)); 18 } 19 assertNodeNumbers(JsonNode n, int expInt, double expDouble)20 protected void assertNodeNumbers(JsonNode n, int expInt, double expDouble) 21 { 22 assertEquals(expInt, n.asInt()); 23 assertEquals(expInt, n.asInt(-42)); 24 assertEquals((long) expInt, n.asLong()); 25 assertEquals((long) expInt, n.asLong(19L)); 26 assertEquals(expDouble, n.asDouble()); 27 assertEquals(expDouble, n.asDouble(-19.25)); 28 29 assertTrue(n.isEmpty()); 30 } 31 } 32