-
-
Notifications
You must be signed in to change notification settings - Fork 799
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Negative number issue (2.13 branch - tests only) (#781)
- Loading branch information
Showing
2 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
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
45 changes: 45 additions & 0 deletions
45
src/test/java/com/fasterxml/jackson/failing/FailingNonStandardNumberParsingTest.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,45 @@ | ||
package com.fasterxml.jackson.failing; | ||
|
||
import com.fasterxml.jackson.core.BaseTest; | ||
import com.fasterxml.jackson.core.JsonFactory; | ||
import com.fasterxml.jackson.core.JsonParser; | ||
import com.fasterxml.jackson.core.JsonToken; | ||
import com.fasterxml.jackson.core.json.JsonReadFeature; | ||
|
||
public class FailingNonStandardNumberParsingTest | ||
extends BaseTest | ||
{ | ||
private final JsonFactory JSON_F = JsonFactory.builder() | ||
.enable(JsonReadFeature.ALLOW_LEADING_DECIMAL_POINT_FOR_NUMBERS) | ||
.build(); | ||
|
||
protected JsonFactory jsonFactory() { | ||
return JSON_F; | ||
} | ||
|
||
public void testLeadingDotInNegativeDecimalAllowedAsync() throws Exception { | ||
_testLeadingDotInNegativeDecimalAllowed(jsonFactory(), MODE_DATA_INPUT); | ||
} | ||
|
||
public void testLeadingDotInNegativeDecimalAllowedBytes() throws Exception { | ||
_testLeadingDotInNegativeDecimalAllowed(jsonFactory(), MODE_INPUT_STREAM); | ||
_testLeadingDotInNegativeDecimalAllowed(jsonFactory(), MODE_INPUT_STREAM_THROTTLED); | ||
} | ||
|
||
public void testLeadingDotInNegativeDecimalAllowedReader() throws Exception { | ||
_testLeadingDotInNegativeDecimalAllowed(jsonFactory(), MODE_READER); | ||
} | ||
|
||
private void _testLeadingDotInNegativeDecimalAllowed(JsonFactory f, int mode) throws Exception | ||
{ | ||
JsonParser p = createParser(f, mode, " -.125 "); | ||
try { | ||
assertEquals(JsonToken.VALUE_NUMBER_FLOAT, p.nextToken()); | ||
assertEquals(-0.125, p.getValueAsDouble()); | ||
assertEquals("-0.125", p.getDecimalValue().toString()); | ||
assertEquals("-.125", p.getText()); | ||
} finally { | ||
p.close(); | ||
} | ||
} | ||
} |