Skip to content

Commit

Permalink
Correct multiarg method tests and add saturating
Browse files Browse the repository at this point in the history
  • Loading branch information
BioTurboNick committed May 27, 2024
1 parent 805078b commit 12afe1c
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -398,15 +398,20 @@ end
end

@testset "multiargument methods" begin
@test @checked(1 + 4 + 5) == 10
@test_throws OverflowError @checked(typemax(Int) + 1 + 4 + 5)
@test_throws OverflowError @checked(1 + 4 + 5 + typemax(Int))
@test @checked(1.0 + 4 + 5 + typemax(Int)) == 9.223372036854776e18
@test @checked(+(1, 4, 5)) == 10
@test_throws OverflowError @checked(+(typemax(Int), 1, 4, 5))
@test_throws OverflowError @checked(+(1, 4, 5, typemax(Int)))
@test @checked(+(1.0, 4, 5, typemax(Int))) == 9.223372036854776e18

@test @unchecked(1 + 4 + 5) == 10
@test @unchecked(typemax(Int) + 1 + 4 + 5) == 10 + typemax(Int)
@test @unchecked(1 + 4 + 5 + typemax(Int)) == 10 + typemax(Int)
@test @checked(1.0 + 4 + 5 + typemax(Int)) == 9.223372036854776e18
@test @unchecked(+(1, 4, 5)) == 10
@test @unchecked(+(typemax(Int), 1, 4, 5)) == 10 + typemax(Int)
@test @unchecked(+(1, 4, 5, typemax(Int))) == 10 + typemax(Int)
@test @unchecked(+(1.0, 4, 5, typemax(Int))) == 9.223372036854776e18

@test @saturating(+(1, 4, 5)) == 10
@test @saturating(+(typemax(Int), 1, 4, 5)) == typemax(Int)
@test @saturating(+(1, 4, 5, typemax(Int))) == typemax(Int)
@test @saturating(+(1.0, 4, 5, typemax(Int))) == 9.223372036854776e18
end

using SaferIntegers
Expand Down

0 comments on commit 12afe1c

Please sign in to comment.