23
23
import static org .junit .jupiter .api .Assertions .fail ;
24
24
import static org .junit .jupiter .api .DynamicTest .dynamicTest ;
25
25
26
- abstract class AbstractHandPickedTest {
26
+ abstract class AbstractDoubleHandPickedTest {
27
27
28
28
abstract double parse (CharSequence str );
29
29
@@ -82,7 +82,10 @@ List<DynamicNode> dynamicTestsLegalInputsWithPrefixAndSuffix() {
82
82
dynamicTest ("before0x123.4p0after" , () -> testLegalInputWithPrefixAndSuffix ("before0x1234p0after" , 6 , 8 , 0x1234p0 )),
83
83
dynamicTest ("before0x123.45p0after" , () -> testLegalInputWithPrefixAndSuffix ("before0x123.45p0after" , 6 , 10 , 0x123.45p0 )),
84
84
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
+
86
89
87
90
);
88
91
}
@@ -116,6 +119,8 @@ List<DynamicNode> dynamicTestsLegalDecFloatLiterals() {
116
119
dynamicTest ("1e0" , () -> testLegalInput ("1e0" , 1e0 )),
117
120
dynamicTest ("1.e0" , () -> testLegalInput ("1.e0" , 1e0 )),
118
121
dynamicTest (".e2" , () -> testLegalInput (".e2" , 0 )),
122
+ dynamicTest (".8" , () -> testLegalInput (".8" , 0.8 )),
123
+ dynamicTest ("8." , () -> testLegalInput ("8." , 8.0 )),
119
124
dynamicTest ("1e1" , () -> testLegalInput ("1e1" , 1e1 )),
120
125
dynamicTest ("1e+1" , () -> testLegalInput ("1e+1" , 1e+1 )),
121
126
dynamicTest ("1e-1" , () -> testLegalInput ("1e-1" , 1e-1 )),
@@ -196,7 +201,10 @@ List<DynamicNode> dynamicTestsLegalHexFloatLiterals() {
196
201
return Arrays .asList (
197
202
dynamicTest ("0x0.1234ab78p0" , () -> testLegalInput ("0x0.1234ab78p0" , 0x0.1234ab78p0 )),
198
203
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 ))
200
208
);
201
209
}
202
210
@@ -223,11 +231,13 @@ List<DynamicNode> dynamicTestsLegalDecFloatLiteralsExtremeValues() {
223
231
224
232
/**
225
233
* 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)}.
227
235
*/
228
236
@ TestFactory
229
237
List <DynamicNode > dynamicTestsDecFloatLiteralClingerInputClasses () {
230
238
return Arrays .asList (
239
+ dynamicTest ("Inside Clinger fast path \" 1000000000000000000e-340\" )" , () -> testLegalInput (
240
+ "1000000000000000000e-325" )),
231
241
//
232
242
dynamicTest ("Inside Clinger fast path (max_clinger_significand, max_clinger_exponent)" , () -> testLegalInput (
233
243
"9007199254740991e22" )),
@@ -238,13 +248,19 @@ List<DynamicNode> dynamicTestsDecFloatLiteralClingerInputClasses() {
238
248
dynamicTest ("Inside Clinger fast path (min_clinger_significand + 1, min_clinger_exponent)" , () -> testLegalInput (
239
249
"1e-22" )),
240
250
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" ))
242
258
);
243
259
}
244
260
245
261
/**
246
262
* 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)}.
248
264
*/
249
265
@ TestFactory
250
266
List <DynamicNode > dynamicTestsHexFloatLiteralClingerInputClasses () {
@@ -265,21 +281,24 @@ List<DynamicNode> dynamicTestsHexFloatLiteralClingerInputClasses() {
265
281
@ TestFactory
266
282
List <DynamicNode > dynamicTestsLegalHexFloatLiteralsExtremeValues () {
267
283
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 )),
270
286
dynamicTest (Double .toHexString (Double .MAX_VALUE ), () -> testLegalHexInput (
271
- Double .MAX_VALUE ))/* ,
287
+ Double .MAX_VALUE )),
272
288
dynamicTest (Double .toHexString (Double .POSITIVE_INFINITY ), () -> testLegalHexInput (
273
289
Double .POSITIVE_INFINITY )),
274
290
dynamicTest (Double .toHexString (Double .NEGATIVE_INFINITY ), () -> testLegalHexInput (
275
291
Double .NEGATIVE_INFINITY )),
276
292
dynamicTest (Double .toHexString (Double .NaN ), () -> testLegalHexInput (
277
293
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 ))),
278
298
dynamicTest ("Just above MAX_VALUE: 0x1.fffffffffffff8p1023" , () -> testLegalInput (
279
299
"0x1.fffffffffffff8p1023" , Double .POSITIVE_INFINITY )),
280
300
dynamicTest ("Just below MIN_VALUE: 0x0.00000000000008p-1022" , () -> testLegalInput (
281
301
"0x0.00000000000008p-1022" , 0.0 ))
282
- */
283
302
);
284
303
}
285
304
0 commit comments