Skip to content

Commit fc7108a

Browse files
committed
update tests
1 parent 1cf19da commit fc7108a

11 files changed

+606
-28
lines changed

src/test/java/com/fasterxml/jackson/core/io/doubleparser/AbstractHandPickedTest.java renamed to src/test/java/com/fasterxml/jackson/core/io/doubleparser/AbstractDoubleHandPickedTest.java

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import static org.junit.jupiter.api.Assertions.fail;
2424
import static org.junit.jupiter.api.DynamicTest.dynamicTest;
2525

26-
abstract class AbstractHandPickedTest {
26+
abstract class AbstractDoubleHandPickedTest {
2727

2828
abstract double parse(CharSequence str);
2929

@@ -82,7 +82,10 @@ List<DynamicNode> dynamicTestsLegalInputsWithPrefixAndSuffix() {
8282
dynamicTest("before0x123.4p0after", () -> testLegalInputWithPrefixAndSuffix("before0x1234p0after", 6, 8, 0x1234p0)),
8383
dynamicTest("before0x123.45p0after", () -> testLegalInputWithPrefixAndSuffix("before0x123.45p0after", 6, 10, 0x123.45p0)),
8484
dynamicTest("Outside Clinger fast path (min_clinger_significand + 1, min_clinger_exponent - 1)", () -> testLegalInputWithPrefixAndSuffix(
85-
"before1e-23after", 6, 5, 1e-23))
85+
"before1e-23after", 6, 5, 1e-23)),
86+
dynamicTest("before9007199254740992.e-256after", () -> testLegalInputWithPrefixAndSuffix(
87+
"before9007199254740992.e-256after", 6, 22, 9007199254740992.e-256))
88+
8689

8790
);
8891
}
@@ -116,6 +119,8 @@ List<DynamicNode> dynamicTestsLegalDecFloatLiterals() {
116119
dynamicTest("1e0", () -> testLegalInput("1e0", 1e0)),
117120
dynamicTest("1.e0", () -> testLegalInput("1.e0", 1e0)),
118121
dynamicTest(".e2", () -> testLegalInput(".e2", 0)),
122+
dynamicTest(".8", () -> testLegalInput(".8", 0.8)),
123+
dynamicTest("8.", () -> testLegalInput("8.", 8.0)),
119124
dynamicTest("1e1", () -> testLegalInput("1e1", 1e1)),
120125
dynamicTest("1e+1", () -> testLegalInput("1e+1", 1e+1)),
121126
dynamicTest("1e-1", () -> testLegalInput("1e-1", 1e-1)),
@@ -196,7 +201,10 @@ List<DynamicNode> dynamicTestsLegalHexFloatLiterals() {
196201
return Arrays.asList(
197202
dynamicTest("0x0.1234ab78p0", () -> testLegalInput("0x0.1234ab78p0", 0x0.1234ab78p0)),
198203
dynamicTest("0x0.1234AB78p0", () -> testLegalInput("0x0.1234AB78p0", 0x0.1234AB78p0)),
199-
dynamicTest("0x1.0p8", () -> testLegalInput("0x1.0p8", 256))
204+
dynamicTest("0x1.0p8", () -> testLegalInput("0x1.0p8", 256)),
205+
dynamicTest("0x1.234567890abcdefp123", () -> testLegalInput("0x1.234567890abcdefp123", 0x1.234567890abcdefp123)),
206+
dynamicTest("0x1234567890.abcdefp-45", () -> testLegalInput("0x1234567890.abcdefp-45", 0x1234567890.abcdefp-45)),
207+
dynamicTest("0x1234567890.abcdef12p-45", () -> testLegalInput("0x1234567890.abcdef12p-45", 0x1234567890.abcdef12p-45))
200208
);
201209
}
202210

@@ -223,11 +231,13 @@ List<DynamicNode> dynamicTestsLegalDecFloatLiteralsExtremeValues() {
223231

224232
/**
225233
* Tests input classes that execute different code branches in
226-
* method {@link FastDoubleMath#tryDecToDoubleWithFastAlgorithm(boolean, long, int)}.
234+
* method {@link FastDoubleMath#tryDecFloatToDouble(boolean, long, int)}.
227235
*/
228236
@TestFactory
229237
List<DynamicNode> dynamicTestsDecFloatLiteralClingerInputClasses() {
230238
return Arrays.asList(
239+
dynamicTest("Inside Clinger fast path \"1000000000000000000e-340\")", () -> testLegalInput(
240+
"1000000000000000000e-325")),
231241
//
232242
dynamicTest("Inside Clinger fast path (max_clinger_significand, max_clinger_exponent)", () -> testLegalInput(
233243
"9007199254740991e22")),
@@ -238,13 +248,19 @@ List<DynamicNode> dynamicTestsDecFloatLiteralClingerInputClasses() {
238248
dynamicTest("Inside Clinger fast path (min_clinger_significand + 1, min_clinger_exponent)", () -> testLegalInput(
239249
"1e-22")),
240250
dynamicTest("Outside Clinger fast path (min_clinger_significand + 1, min_clinger_exponent - 1)", () -> testLegalInput(
241-
"1e-23"))
251+
"1e-23")),
252+
dynamicTest("Outside Clinger fast path, bail-out in semi-fast path, 1e23", () -> testLegalInput(
253+
"1e23")),
254+
dynamicTest("Outside Clinger fast path, mantissa overflows in semi-fast path, 7.2057594037927933e+16", () -> testLegalInput(
255+
"7.2057594037927933e+16")),
256+
dynamicTest("Outside Clinger fast path, bail-out in semi-fast path, 7.3177701707893310e+15", () -> testLegalInput(
257+
"7.3177701707893310e+15"))
242258
);
243259
}
244260

245261
/**
246262
* Tests input classes that execute different code branches in
247-
* method {@link FastDoubleMath#tryHexToDoubleWithFastAlgorithm(boolean, long, int)}.
263+
* method {@link FastDoubleMath#tryHexFloatToDouble(boolean, long, int)}.
248264
*/
249265
@TestFactory
250266
List<DynamicNode> dynamicTestsHexFloatLiteralClingerInputClasses() {
@@ -265,21 +281,24 @@ List<DynamicNode> dynamicTestsHexFloatLiteralClingerInputClasses() {
265281
@TestFactory
266282
List<DynamicNode> dynamicTestsLegalHexFloatLiteralsExtremeValues() {
267283
return Arrays.asList(
268-
/*dynamicTest(Double.toHexString(Double.MIN_VALUE), () -> testLegalHexInput(
269-
Double.MIN_VALUE)),*/
284+
dynamicTest(Double.toHexString(Double.MIN_VALUE), () -> testLegalHexInput(
285+
Double.MIN_VALUE)),
270286
dynamicTest(Double.toHexString(Double.MAX_VALUE), () -> testLegalHexInput(
271-
Double.MAX_VALUE))/*,
287+
Double.MAX_VALUE)),
272288
dynamicTest(Double.toHexString(Double.POSITIVE_INFINITY), () -> testLegalHexInput(
273289
Double.POSITIVE_INFINITY)),
274290
dynamicTest(Double.toHexString(Double.NEGATIVE_INFINITY), () -> testLegalHexInput(
275291
Double.NEGATIVE_INFINITY)),
276292
dynamicTest(Double.toHexString(Double.NaN), () -> testLegalHexInput(
277293
Double.NaN)),
294+
dynamicTest(Double.toHexString(Math.nextUp(0.0)), () -> testLegalHexInput(
295+
Math.nextUp(0.0))),
296+
dynamicTest(Double.toHexString(Math.nextDown(0.0)), () -> testLegalHexInput(
297+
Math.nextDown(0.0))),
278298
dynamicTest("Just above MAX_VALUE: 0x1.fffffffffffff8p1023", () -> testLegalInput(
279299
"0x1.fffffffffffff8p1023", Double.POSITIVE_INFINITY)),
280300
dynamicTest("Just below MIN_VALUE: 0x0.00000000000008p-1022", () -> testLegalInput(
281301
"0x0.00000000000008p-1022", 0.0))
282-
*/
283302
);
284303
}
285304

0 commit comments

Comments
 (0)