Skip to content

Commit a18cf59

Browse files
committed
Add test coverage.
1 parent b5f88da commit a18cf59

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

test/runtests.jl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,34 @@ end
190190

191191
#==Integer values: Formatting
192192
===============================================================================#
193+
@test formatted(0, :SI, ndigits=0) == "0" #Ensure not "0.00000000..."
193194
@test formatted(27_182_818_284, :SI, ndigits=3) == "27.2G"
194195
@test formatted(27_182_818_284, :ENG, ndigits=3) == "27.2×10⁹"
195196
@test formatted(27_182_818_284, :SCI, ndigits=3) == "2.72×10¹⁰"
196197
@test formatted(27_182_818_284, :SCI, ndigits=3, charset=:ASCII) == "2.72E10"
197198

198199

200+
#==Max ndigits, fixed decpos
201+
===============================================================================#
202+
fmt = NumericIO.IOFormattingReal(NumericIO.UEXPONENT_SI,
203+
ndigits=0, decpos=9, decfloating=false, eng=true,
204+
minus=NumericIO.UTF8_MINUS_SYMBOL, inf=NumericIO.UTF8_INF_STRING
205+
)
206+
newscope() do
207+
SI(v) = formatted(v, fmt)
208+
@test SI(0) == "0G" #Ensure not "0.00000000...G"
209+
@test SI(2.718281828459045e5) == "0.0002718281828459045G"
210+
@test SI(2.718281828459045e6) == "0.002718281828459045G"
211+
@test SI(2.718281828459045e7) == "0.02718281828459045G"
212+
@test SI(2.718281828459045e8) == "0.2718281828459045G"
213+
@test SI(2.718281828459045e9) == "2.718281828459045G"
214+
@test SI(2.718281828459045e10) == "27.18281828459045G"
215+
@test SI(2.718281828459045e11) == "271.8281828459045G"
216+
@test SI(2.718281828459045e12) == "2718.281828459045G"
217+
@test SI(2.718281828459045e13) == "27182.81828459045G"
218+
end
219+
220+
199221
#==Fixed ndigits, fixed decpos
200222
===============================================================================#
201223
#Use lower-level structures for fixed decimal position:
@@ -205,6 +227,7 @@ fmt = NumericIO.IOFormattingReal(NumericIO.UEXPONENT_SI,
205227
)
206228
newscope() do
207229
SI(v) = formatted(v, fmt)
230+
@test SI(0.75e9) == "0.750G"
208231
@test SI(2.718281828459045e5) == "0.000G"
209232
@test SI(2.718281828459045e6) == "0.003G"
210233
@test SI(2.718281828459045e7) == "0.027G"

0 commit comments

Comments
 (0)