From 8c700f55dc5bcadebed5a32bea2ab7ecf8acfe40 Mon Sep 17 00:00:00 2001 From: Cowtowncoder Date: Wed, 8 Oct 2014 16:10:42 -0700 Subject: [PATCH] Add a regression test for #157; was NOT failing on 2.3 (i.e. regression in 2.4) --- .../jackson/core/json/TestNumericValues.java | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/fasterxml/jackson/core/json/TestNumericValues.java b/src/test/java/com/fasterxml/jackson/core/json/TestNumericValues.java index 17b1cf12f0..16366faef7 100644 --- a/src/test/java/com/fasterxml/jackson/core/json/TestNumericValues.java +++ b/src/test/java/com/fasterxml/jackson/core/json/TestNumericValues.java @@ -368,14 +368,38 @@ public void testParsingOfLongerSequences() } } + // [jackson-core#157] + public void testLongNumbers() throws Exception + { + StringBuilder sb = new StringBuilder(9000); + for (int i = 0; i < 9000; ++i) { + sb.append('9'); + } + String NUM = sb.toString(); + JsonFactory f = new JsonFactory(); + _testLongNumbers(f, NUM, false); + _testLongNumbers(f, NUM, true); + } + + private void _testLongNumbers(JsonFactory f, String num, boolean useStream) throws Exception + { + final String doc = "[ "+num+" ]"; + JsonParser jp = useStream + ? f.createParser(doc.getBytes("UTF-8")) + : f.createParser(doc); + assertToken(JsonToken.START_ARRAY, jp.nextToken()); + assertToken(JsonToken.VALUE_NUMBER_INT, jp.nextToken()); + assertEquals(num, jp.getText()); + assertToken(JsonToken.END_ARRAY, jp.nextToken()); + } + /* /********************************************************** /* Tests for invalid access /********************************************************** */ - public void testInvalidBooleanAccess() - throws Exception + public void testInvalidBooleanAccess() throws Exception { JsonParser jp = createParserUsingReader("[ \"abc\" ]"); assertToken(JsonToken.START_ARRAY, jp.nextToken());