-
-
Notifications
You must be signed in to change notification settings - Fork 781
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new failing tests to help investigation
- Loading branch information
1 parent
9d2bccc
commit eb85a33
Showing
2 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
src/test/java/com/fasterxml/jackson/failing/PerfBigDecimalParser967.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.fasterxml.jackson.failing; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import com.fasterxml.jackson.core.*; | ||
|
||
// For [core#967] | ||
public class PerfBigDecimalParser967 | ||
{ | ||
private final JsonFactory JSON_F = new JsonFactory(); | ||
|
||
// For [core#967]: shouldn't take multiple seconds | ||
@Test(timeout = 35000) | ||
public void bigDecimalFromString() throws Exception { | ||
// Jackson's BigDecimalParser seems to be slower than JDK's; | ||
// won't fail if using latter. | ||
StringBuilder sb = new StringBuilder(900); | ||
for (int i = 0; i < 500; ++i) { | ||
sb.append('1'); | ||
} | ||
sb.append("1e10000000"); | ||
final String DOC = sb.toString(); | ||
|
||
try (JsonParser p = JSON_F.createParser(DOC)) { | ||
assertToken(JsonToken.VALUE_NUMBER_FLOAT, p.nextToken()); | ||
Assert.assertNotNull(p.getDecimalValue()); | ||
} | ||
} | ||
|
||
protected void assertToken(JsonToken expToken, JsonToken actToken) | ||
{ | ||
if (actToken != expToken) { | ||
Assert.fail("Expected token "+expToken+", current token "+actToken); | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/test/java/com/fasterxml/jackson/failing/PerfBigDecimalToInteger968.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.fasterxml.jackson.failing; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import com.fasterxml.jackson.core.*; | ||
|
||
// For [core#968]] | ||
public class PerfBigDecimalToInteger968 | ||
{ | ||
private final JsonFactory JSON_F = new JsonFactory(); | ||
|
||
// For [core#968]]: shouldn't take multiple seconds | ||
@Test(timeout = 3000) | ||
public void bigIntegerViaBigDecimal() throws Exception { | ||
final String DOC = "1e20000000"; | ||
|
||
try (JsonParser p = JSON_F.createParser(DOC)) { | ||
assertToken(JsonToken.VALUE_NUMBER_FLOAT, p.nextToken()); | ||
Assert.assertNotNull(p.getBigIntegerValue()); | ||
} | ||
} | ||
|
||
protected void assertToken(JsonToken expToken, JsonToken actToken) | ||
{ | ||
if (actToken != expToken) { | ||
Assert.fail("Expected token "+expToken+", current token "+actToken); | ||
} | ||
} | ||
} |