Skip to content

Commit

Permalink
Add tests for FixedRational -> Bool
Browse files Browse the repository at this point in the history
  • Loading branch information
MilesCranmer committed Nov 1, 2023
1 parent f185a56 commit 3ac5111
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/unittests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,11 @@ end
@testset "Additional tests of FixedRational" begin
@test convert(Int64, FixedRational{Int64,1000}(2 // 1)) == 2
@test convert(Int32, FixedRational{Int64,1000}(3 // 1)) == 3
@test convert(Bool, FixedRational{Int8,6}(1//1)) === true
@test convert(Bool, FixedRational{Int8,6}(0//1)) === false

@test_throws InexactError convert(Int32, FixedRational{Int8,6}(2//3))
@test_throws InexactError convert(Bool, FixedRational{Int8,6}(2//1))

VERSION >= v"1.8" && @test_throws "Refusing to" promote(FixedRational{Int,10}(2), FixedRational{Int,4}(2))

Expand Down

0 comments on commit 3ac5111

Please sign in to comment.