@@ -19,6 +19,34 @@ todouble(sign, exp, mant) = Core.bitcast(Float64, (UInt64(sign) << 63) | (UInt64
19
19
@test Ryu. writeshortest (- Inf ) == " -Inf"
20
20
end
21
21
22
+ @testset " OutputOptions" begin
23
+ # plus
24
+ @test " +1" == Base. Ryu. writeshortest (1.0 , true , false , false )
25
+ @test " -1" == Base. Ryu. writeshortest (- 1.0 , true , false , false )
26
+
27
+ # space
28
+ @test " 1" == Ryu. writeshortest (1.0 , false , true , false )
29
+
30
+ # hash
31
+ @test " 0" == Ryu. writeshortest (0.0 , false , false , false )
32
+
33
+ # precision
34
+ @test " 9.9900" == Ryu. writeshortest (9.99 , false , false , true , 5 )
35
+ @test " 1." == Ryu. writeshortest (1.0 , false , false , true , 1 )
36
+
37
+ # expchar
38
+ @test " 1.0d6" == Ryu. writeshortest (1e6 , false , false , true , - 1 , UInt8 (' d' ))
39
+
40
+ # padexp
41
+ @test " 3.0e+08" == Ryu. writeshortest (3e8 , false , false , true , - 1 , UInt8 (' e' ), true )
42
+
43
+ # decchar
44
+ @test " 3,14" == Ryu. writeshortest (3.14 , false , false , true , - 1 , UInt8 (' e' ), false , UInt8 (' ,' ))
45
+
46
+ # compact
47
+ @test " 0.333333" == Ryu. writeshortest (1 / 3 , false , false , true , - 1 , UInt8 (' e' ), false , UInt8 (' .' ), false , true )
48
+ end
49
+
22
50
@testset " SwitchToSubnormal" begin
23
51
@test " 2.2250738585072014e-308" == Ryu. writeshortest (2.2250738585072014e-308 )
24
52
end
@@ -241,6 +269,17 @@ end # Float64
241
269
@test " -Inf" == Ryu. writeshortest (Float32 (- Inf ))
242
270
end
243
271
272
+ @testset " OutputOptions" begin
273
+ # typed
274
+ @test " 1.0f0" == Ryu. writeshortest (Float32 (1.0 ), false , false , true , - 1 , UInt8 (' e' ), false , UInt8 (' .' ), true )
275
+ @test " Inf32" == Ryu. writeshortest (Float32 (Inf ), false , false , true , - 1 , UInt8 (' e' ), false , UInt8 (' .' ), true )
276
+ @test " NaN32" == Ryu. writeshortest (Float32 (NaN ), false , false , true , - 1 , UInt8 (' e' ), false , UInt8 (' .' ), true )
277
+ @test " 3.14f0" == Ryu. writeshortest (Float32 (3.14 ), false , false , true , - 1 , UInt8 (' e' ), false , UInt8 (' .' ), true )
278
+
279
+ # typed and no-hash
280
+ @test " 1f0" == Ryu. writeshortest (1.0f0 , false , false , false , - 1 , UInt8 (' e' ), false , UInt8 (' .' ), true )
281
+ end
282
+
244
283
@testset " SwitchToSubnormal" begin
245
284
@test " 1.1754944e-38" == Ryu. writeshortest (1.1754944f-38 )
246
285
end
@@ -341,6 +380,17 @@ end # Float32
341
380
@test " -Inf" == Ryu. writeshortest (Float16 (- Inf ))
342
381
end
343
382
383
+ @testset " OutputOptions" begin
384
+ # typed
385
+ @test " Float16(1.0)" == Ryu. writeshortest (Float16 (1.0 ), false , false , true , - 1 , UInt8 (' e' ), false , UInt8 (' .' ), true )
386
+ @test " Inf16" == Ryu. writeshortest (Float16 (Inf ), false , false , true , - 1 , UInt8 (' e' ), false , UInt8 (' .' ), true )
387
+ @test " NaN16" == Ryu. writeshortest (Float16 (NaN ), false , false , true , - 1 , UInt8 (' e' ), false , UInt8 (' .' ), true )
388
+ @test " Float16(3.14)" == Ryu. writeshortest (Float16 (3.14 ), false , false , true , - 1 , UInt8 (' e' ), false , UInt8 (' .' ), true )
389
+
390
+ # typed and no-hash
391
+ @test " Float16(1)" == Ryu. writeshortest (Float16 (1.0 ), false , false , false , - 1 , UInt8 (' e' ), false , UInt8 (' .' ), true )
392
+ end
393
+
344
394
let x= floatmin (Float16)
345
395
while x <= floatmax (Float16)
346
396
@test parse (Float16, Ryu. writeshortest (x)) == x
0 commit comments