Skip to content

Commit 97b9c29

Browse files
jmkuhnstevengj
authored andcommitted
Enable Dec128 @sprintf tests (#66)
1 parent dfddeec commit 97b9c29

File tree

1 file changed

+41
-44
lines changed

1 file changed

+41
-44
lines changed

test/runtests.jl

Lines changed: 41 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -61,50 +61,47 @@ for T in (Dec32, Dec64, Dec128)
6161
show(io, T("123.456")); @test String(take!(io)) == "123.456"
6262
show(io, T("0.00123456")); @test String(take!(io)) == "0.00123456"
6363

64-
# some Dec128 tests fail due to Issue #47
65-
if T != Dec128
66-
@test @sprintf("%7.2f", T("1.2345")) == " 1.23"
67-
@test @sprintf("%-7.2f", T("1.2345")) == "1.23 "
68-
@test @sprintf("%07.2f", T("1.2345")) == "0001.23"
69-
@test @sprintf("%.0f", T("1.2345")) == "1"
70-
@test @sprintf("%#.0f", T("1.2345")) == "1."
71-
@test @sprintf("%.4e", T("1.2345")) == "1.2345e+00"
72-
@test @sprintf("%.4E", T("1.2345")) == "1.2345E+00"
73-
74-
@test @sprintf("%6.2f", T("9.999")) == " 10.00"
75-
@test @sprintf("%9.2e", T("9.999e5")) == " 1.00e+06"
76-
77-
@test @sprintf("%f", T("Inf")) == "Inf"
78-
@test @sprintf("%f", T("NaN")) == "NaN"
79-
80-
@test @sprintf("%.0e", T("3e42")) == "3e+42"
81-
@test @sprintf("%#.0e", T("3e42")) == "3.e+42"
82-
83-
@test @sprintf("%e", T("3e42")) == "3.000000e+42"
84-
@test @sprintf("%E", T("3e42")) == "3.000000E+42"
85-
@test @sprintf("%e", T("3e-42")) == "3.000000e-42"
86-
@test @sprintf("%E", T("3e-42")) == "3.000000E-42"
87-
88-
@sprintf("%.6g", T("12345670.")) == "1.23457e+07"
89-
@sprintf("%.6g", T("1234567.")) == "1.23457e+06"
90-
@sprintf("%.6g", T("123456.7")) == "123457"
91-
@sprintf("%.6g", T("12345.67")) == "12345.7"
92-
@sprintf("%.6g", T("12340000.0")) == "1.234e+07"
93-
94-
@test @sprintf("%10.5g", T("123.4")) == " 123.4"
95-
@test @sprintf("%+10.5g", T("123.4")) == " +123.4"
96-
@test @sprintf("% 10.5g", T("123.4")) == " 123.4"
97-
@test @sprintf("%#10.5g", T("123.4")) == " 123.40"
98-
@test @sprintf("%-10.5g", T("123.4")) == "123.4 "
99-
@test @sprintf("%-+10.5g", T("123.4")) == "+123.4 "
100-
@test @sprintf("%010.5g", T("123.4")) == "00000123.4"
101-
@test @sprintf("%10.5g", T("-123.4")) == " -123.4"
102-
@test @sprintf("%010.5g", T("-123.4")) == "-0000123.4"
103-
@test @sprintf("%.6g", T("12340000.0")) == "1.234e+07"
104-
@test @sprintf("%#.6g", T("12340000.0")) == "1.23400e+07"
105-
106-
@test @sprintf("%.2f %.4f", T("12.34567"), 9.87) == "12.35 9.8700"
107-
end
64+
@test @sprintf("%7.2f", T("1.2345")) == " 1.23"
65+
@test @sprintf("%-7.2f", T("1.2345")) == "1.23 "
66+
@test @sprintf("%07.2f", T("1.2345")) == "0001.23"
67+
@test @sprintf("%.0f", T("1.2345")) == "1"
68+
@test @sprintf("%#.0f", T("1.2345")) == "1."
69+
@test @sprintf("%.4e", T("1.2345")) == "1.2345e+00"
70+
@test @sprintf("%.4E", T("1.2345")) == "1.2345E+00"
71+
72+
@test @sprintf("%6.2f", T("9.999")) == " 10.00"
73+
@test @sprintf("%9.2e", T("9.999e5")) == " 1.00e+06"
74+
75+
@test @sprintf("%f", T("Inf")) == "Inf"
76+
@test @sprintf("%f", T("NaN")) == "NaN"
77+
78+
@test @sprintf("%.0e", T("3e42")) == "3e+42"
79+
@test @sprintf("%#.0e", T("3e42")) == "3.e+42"
80+
81+
@test @sprintf("%e", T("3e42")) == "3.000000e+42"
82+
@test @sprintf("%E", T("3e42")) == "3.000000E+42"
83+
@test @sprintf("%e", T("3e-42")) == "3.000000e-42"
84+
@test @sprintf("%E", T("3e-42")) == "3.000000E-42"
85+
86+
@sprintf("%.6g", T("12345670.")) == "1.23457e+07"
87+
@sprintf("%.6g", T("1234567.")) == "1.23457e+06"
88+
@sprintf("%.6g", T("123456.7")) == "123457"
89+
@sprintf("%.6g", T("12345.67")) == "12345.7"
90+
@sprintf("%.6g", T("12340000.0")) == "1.234e+07"
91+
92+
@test @sprintf("%10.5g", T("123.4")) == " 123.4"
93+
@test @sprintf("%+10.5g", T("123.4")) == " +123.4"
94+
@test @sprintf("% 10.5g", T("123.4")) == " 123.4"
95+
@test @sprintf("%#10.5g", T("123.4")) == " 123.40"
96+
@test @sprintf("%-10.5g", T("123.4")) == "123.4 "
97+
@test @sprintf("%-+10.5g", T("123.4")) == "+123.4 "
98+
@test @sprintf("%010.5g", T("123.4")) == "00000123.4"
99+
@test @sprintf("%10.5g", T("-123.4")) == " -123.4"
100+
@test @sprintf("%010.5g", T("-123.4")) == "-0000123.4"
101+
@test @sprintf("%.6g", T("12340000.0")) == "1.234e+07"
102+
@test @sprintf("%#.6g", T("12340000.0")) == "1.23400e+07"
103+
104+
@test @sprintf("%.2f %.4f", T("12.34567"), 9.87) == "12.35 9.8700"
108105

109106
x,y,z = 1.5, -3.25, 0.0625 # exactly represented in binary
110107
xd = T(x); yd = T(y); zd = T(z)

0 commit comments

Comments
 (0)