public void testMinMaxInts() throws IOException { byte[] data = _smileDoc(String.valueOf(Integer.MAX_VALUE)); SmileParser p = _smileParser(data); assertToken(JsonToken.VALUE_NUMBER_INT, p.nextToken()); assertEquals(JsonParser.NumberType.INT, p.getNumberType()); assertEquals(Integer.MAX_VALUE, p.getIntValue()); p.close(); data = _smileDoc(String.valueOf(Integer.MIN_VALUE)); p = _smileParser(data); assertToken(JsonToken.VALUE_NUMBER_INT, p.nextToken()); assertEquals(JsonParser.NumberType.INT, p.getNumberType()); assertEquals(Integer.MIN_VALUE, p.getIntValue()); p.close(); }
public void testIntsMedium() throws IOException { byte[] data = _smileDoc("255"); SmileParser p = _smileParser(data); assertToken(JsonToken.VALUE_NUMBER_INT, p.nextToken()); assertEquals(255, p.getIntValue()); assertEquals("255", p.getText()); data = _smileDoc("-999"); p.close(); p = _smileParser(data); assertToken(JsonToken.VALUE_NUMBER_INT, p.nextToken()); assertEquals(JsonParser.NumberType.INT, p.getNumberType()); assertEquals(-999, p.getIntValue()); assertEquals("-999", p.getText()); p.close(); data = _smileDoc("123456789"); p = _smileParser(data); assertToken(JsonToken.VALUE_NUMBER_INT, p.nextToken()); assertEquals(JsonParser.NumberType.INT, p.getNumberType()); assertEquals(123456789, p.getIntValue()); p.close(); }
public void testArrayWithInts() throws IOException { byte[] data = _smileDoc( "[ 1, 0, -1, 255, -999, " + Integer.MIN_VALUE + "," + Integer.MAX_VALUE + "," + Long.MIN_VALUE + ", " + Long.MAX_VALUE + " ]"); SmileParser p = _smileParser(data); assertNull(p.getCurrentToken()); assertToken(JsonToken.START_ARRAY, p.nextToken()); assertToken(JsonToken.VALUE_NUMBER_INT, p.nextToken()); assertEquals(1, p.getIntValue()); assertEquals(JsonParser.NumberType.INT, p.getNumberType()); assertToken(JsonToken.VALUE_NUMBER_INT, p.nextToken()); assertEquals(0, p.getIntValue()); assertEquals(JsonParser.NumberType.INT, p.getNumberType()); assertToken(JsonToken.VALUE_NUMBER_INT, p.nextToken()); assertEquals(-1, p.getIntValue()); assertEquals(JsonParser.NumberType.INT, p.getNumberType()); assertToken(JsonToken.VALUE_NUMBER_INT, p.nextToken()); assertEquals(255, p.getIntValue()); assertEquals(JsonParser.NumberType.INT, p.getNumberType()); assertToken(JsonToken.VALUE_NUMBER_INT, p.nextToken()); assertEquals(-999, p.getIntValue()); assertEquals(JsonParser.NumberType.INT, p.getNumberType()); assertToken(JsonToken.VALUE_NUMBER_INT, p.nextToken()); assertEquals(JsonParser.NumberType.INT, p.getNumberType()); assertEquals(Integer.MIN_VALUE, p.getIntValue()); assertToken(JsonToken.VALUE_NUMBER_INT, p.nextToken()); assertEquals(Integer.MAX_VALUE, p.getIntValue()); assertEquals(JsonParser.NumberType.INT, p.getNumberType()); assertToken(JsonToken.VALUE_NUMBER_INT, p.nextToken()); assertEquals(JsonParser.NumberType.LONG, p.getNumberType()); assertEquals(Long.MIN_VALUE, p.getLongValue()); assertToken(JsonToken.VALUE_NUMBER_INT, p.nextToken()); assertEquals(Long.MAX_VALUE, p.getLongValue()); assertEquals(JsonParser.NumberType.LONG, p.getNumberType()); assertToken(JsonToken.END_ARRAY, p.nextToken()); p.close(); }