Skip to content

Commit df44234

Browse files
committed
Add bigint tests
1 parent 8840f83 commit df44234

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test/FixedDecimal.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,21 @@ end
298298
@test_throws InexactError(:convert, FD2, typemax(UInt128)) convert(FD2, typemax(UInt128))
299299
@test_throws InexactError(:convert, UFD2, typemax(UInt128)) convert(UFD2, typemax(UInt128))
300300
end
301+
302+
@testset "Convert from BigInt to 128-bit" begin
303+
@test convert(WFD2, BigInt(1)).i === Int128(100)
304+
@test convert(UWFD2, BigInt(1)).i === UInt128(100)
305+
@test convert(WFD2, BigInt(-1)).i === Int128(-100)
306+
@test_throws InexactError(:convert, UWFD2, BigInt(-1)) convert(UWFD2, BigInt(-1))
307+
@test_throws InexactError(:convert, FD2, BigInt(typemax(Int128))) convert(FD2, BigInt(typemax(Int128)))
308+
end
309+
310+
@testset "Convert from 128-bit to BigInt" begin
311+
@test convert(FixedDecimal{BigInt,2}, Int128(1)).i == BigInt(100)
312+
@test convert(FixedDecimal{BigInt,2}, UInt128(1)).i == BigInt(100)
313+
@test convert(FixedDecimal{BigInt,2}, Int128(-1)).i == BigInt(-100)
314+
@test convert(FixedDecimal{BigInt,2}, typemax(UInt128)).i == BigInt(typemax(UInt128))*100
315+
end
301316
end
302317

303318
module PerfTests

0 commit comments

Comments
 (0)