use of com.fasterxml.jackson.core.testsupport.AsyncReaderWrapper in project jackson-core by FasterXML.
the class AsyncScalarArrayTest method _testFloats.
private void _testFloats(JsonFactory f, float[] values, byte[] data, int offset, int readSize) throws IOException {
AsyncReaderWrapper r = asyncForBytes(f, readSize, data, offset);
// start with "no token"
assertNull(r.currentToken());
assertToken(JsonToken.START_ARRAY, r.nextToken());
for (int i = 0; i < values.length; ++i) {
assertToken(JsonToken.VALUE_NUMBER_FLOAT, r.nextToken());
assertEquals(values[i], r.getFloatValue());
// json can't distinguish floats from doubles so
assertEquals(NumberType.DOUBLE, r.getNumberType());
}
assertToken(JsonToken.END_ARRAY, r.nextToken());
// and end up with "no token" as well
assertNull(r.nextToken());
assertTrue(r.isClosed());
}
use of com.fasterxml.jackson.core.testsupport.AsyncReaderWrapper in project jackson-core by FasterXML.
the class AsyncScalarArrayTest method _testBigDecimals.
private void _testBigDecimals(JsonFactory f, BigDecimal[] values, byte[] doc, int offset, int readSize) throws IOException {
AsyncReaderWrapper r = asyncForBytes(f, readSize, doc, offset);
// start with "no token"
assertNull(r.currentToken());
assertToken(JsonToken.START_ARRAY, r.nextToken());
for (int i = 0; i < values.length; ++i) {
BigDecimal expValue = values[i];
assertToken(JsonToken.VALUE_NUMBER_FLOAT, r.nextToken());
assertEquals(expValue, r.getDecimalValue());
assertEquals(NumberType.BIG_DECIMAL, r.getNumberType());
}
assertToken(JsonToken.END_ARRAY, r.nextToken());
assertNull(r.nextToken());
assertTrue(r.isClosed());
}
use of com.fasterxml.jackson.core.testsupport.AsyncReaderWrapper in project jackson-core by FasterXML.
the class AsyncScalarArrayTest method _testDoubles.
private void _testDoubles(JsonFactory f, double[] values, byte[] data, int offset, int readSize) throws IOException {
AsyncReaderWrapper r = asyncForBytes(f, readSize, data, offset);
// start with "no token"
assertNull(r.currentToken());
assertToken(JsonToken.START_ARRAY, r.nextToken());
for (int i = 0; i < values.length; ++i) {
assertToken(JsonToken.VALUE_NUMBER_FLOAT, r.nextToken());
assertEquals(String.format("Entry #%d: %s (textual '%s')", i, values[i], r.currentText()), values[i], r.getDoubleValue());
assertEquals(NumberType.DOUBLE, r.getNumberType());
}
assertToken(JsonToken.END_ARRAY, r.nextToken());
// and end up with "no token" as well
assertNull(r.nextToken());
assertTrue(r.isClosed());
}
use of com.fasterxml.jackson.core.testsupport.AsyncReaderWrapper in project jackson-core by FasterXML.
the class AsyncScalarArrayTest method _testBigIntegers.
private void _testBigIntegers(JsonFactory f, BigInteger[] values, byte[] data, int offset, int readSize) throws IOException {
AsyncReaderWrapper r = asyncForBytes(f, readSize, data, offset);
// start with "no token"
assertNull(r.currentToken());
assertToken(JsonToken.START_ARRAY, r.nextToken());
for (int i = 0; i < values.length; ++i) {
BigInteger expValue = values[i];
assertToken(JsonToken.VALUE_NUMBER_INT, r.nextToken());
assertEquals(expValue, r.getBigIntegerValue());
assertEquals(NumberType.BIG_INTEGER, r.getNumberType());
}
assertToken(JsonToken.END_ARRAY, r.nextToken());
assertNull(r.nextToken());
assertTrue(r.isClosed());
}
use of com.fasterxml.jackson.core.testsupport.AsyncReaderWrapper in project jackson-core by FasterXML.
the class AsyncScalarArrayTest method _testLong.
private void _testLong(JsonFactory f, long[] values, byte[] data, int offset, int readSize) throws IOException {
AsyncReaderWrapper r = asyncForBytes(f, readSize, data, offset);
// start with "no token"
assertNull(r.currentToken());
assertToken(JsonToken.START_ARRAY, r.nextToken());
for (int i = 0; i < values.length; ++i) {
assertToken(JsonToken.VALUE_NUMBER_INT, r.nextToken());
assertEquals(values[i], r.getLongValue());
assertEquals(NumberType.LONG, r.getNumberType());
}
assertToken(JsonToken.END_ARRAY, r.nextToken());
// and end up with "no token" as well
assertNull(r.nextToken());
assertTrue(r.isClosed());
}
Aggregations