Skip to content

Commit

Permalink
move tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pjfanning committed Sep 12, 2024
1 parent 4f540a3 commit 6bb2a0a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ class NonStandardNumberParsingTest
.enable(JsonReadFeature.ALLOW_LEADING_DECIMAL_POINT_FOR_NUMBERS)
.enable(JsonReadFeature.ALLOW_TRAILING_DECIMAL_POINT_FOR_NUMBERS)
.build();
private final String ISSUE_4694_VALUE =
"-11000.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";


protected JsonFactory jsonFactory() {
return JSON_F;
Expand Down Expand Up @@ -246,41 +243,6 @@ void leadingDotInNegativeDecimalAllowedReader() throws Exception {
_testLeadingDotInNegativeDecimalAllowed(jsonFactory(), MODE_READER_THROTTLED);
}

// https://github.com/FasterXML/jackson-databind/issues/4694
@Test
void databind4694() throws Exception {
final BigDecimal expected = new BigDecimal(ISSUE_4694_VALUE);
for (int mode : ALL_MODES) {
try (JsonParser p = createParser(mode, String.format(" %s ", ISSUE_4694_VALUE))) {
assertEquals(JsonToken.VALUE_NUMBER_FLOAT, p.nextToken());
assertEquals(expected, p.getDecimalValue());
assertFalse(p.isNaN());
}
}
}

void databind4694Double() throws Exception {
final Double expected = new Double(ISSUE_4694_VALUE);
for (int mode : ALL_MODES) {
try (JsonParser p = createParser(mode, String.format(" %s ", ISSUE_4694_VALUE))) {
assertEquals(JsonToken.VALUE_NUMBER_FLOAT, p.nextToken());
assertEquals(expected, p.getDoubleValue());
assertFalse(p.isNaN());
}
}
}

void databind4694Float() throws Exception {
final Float expected = new Float(ISSUE_4694_VALUE);
for (int mode : ALL_MODES) {
try (JsonParser p = createParser(mode, String.format(" %s ", ISSUE_4694_VALUE))) {
assertEquals(JsonToken.VALUE_NUMBER_FLOAT, p.nextToken());
assertEquals(expected, p.getFloatValue());
assertFalse(p.isNaN());
}
}
}

private void _testLeadingDotInDecimalAllowed(JsonFactory f, int mode) throws Exception
{
try (JsonParser p = createParser(f, mode, " .125 ")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ protected JsonFactory jsonFactory() {
return sharedStreamFactory();
}

private final String ISSUE_4694_VALUE =
"-11000.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";

/*
/**********************************************************************
/* Tests, Boolean
Expand Down Expand Up @@ -996,6 +999,41 @@ void negativeMaxNumberLength() {
}
}

// https://github.com/FasterXML/jackson-databind/issues/4694
@Test
void databind4694() throws Exception {
final BigDecimal expected = new BigDecimal(ISSUE_4694_VALUE);
for (int mode : ALL_MODES) {
try (JsonParser p = createParser(mode, String.format(" %s ", ISSUE_4694_VALUE))) {
assertEquals(JsonToken.VALUE_NUMBER_FLOAT, p.nextToken());
assertEquals(expected, p.getDecimalValue());
assertFalse(p.isNaN());
}
}
}

void databind4694Double() throws Exception {
final Double expected = new Double(ISSUE_4694_VALUE);
for (int mode : ALL_MODES) {
try (JsonParser p = createParser(mode, String.format(" %s ", ISSUE_4694_VALUE))) {
assertEquals(JsonToken.VALUE_NUMBER_FLOAT, p.nextToken());
assertEquals(expected, p.getDoubleValue());
assertFalse(p.isNaN());
}
}
}

void databind4694Float() throws Exception {
final Float expected = new Float(ISSUE_4694_VALUE);
for (int mode : ALL_MODES) {
try (JsonParser p = createParser(mode, String.format(" %s ", ISSUE_4694_VALUE))) {
assertEquals(JsonToken.VALUE_NUMBER_FLOAT, p.nextToken());
assertEquals(expected, p.getFloatValue());
assertFalse(p.isNaN());
}
}
}

/*
/**********************************************************
/* Helper methods
Expand Down

0 comments on commit 6bb2a0a

Please sign in to comment.