Skip to content

Commit

Permalink
test: Base.GMP.MPZ.invert and Base.GMP.MPZ.invert!
Browse files Browse the repository at this point in the history
  • Loading branch information
NegaScout committed Dec 23, 2024
1 parent 00cda38 commit 9eb202f
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/gmp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,34 @@ end
end
end

@testset "modular invert" begin
# test invert is correct and does not mutate
a = BigInt(3)
b = BigInt(7)
i = BigInt(5)
@test Base.GMP.MPZ.invert(a, b) == i
@test a == BigInt(3)
@test b == BigInt(7)

# test in place invert does mutate first argument
a = BigInt(3)
b = BigInt(7)
i = BigInt(5)
i_inplace = BigInt(3)
Base.GMP.MPZ.invert!(i_inplace, b)
@test i_inplace == i

# test in place invert does mutate only first argument
a = BigInt(3)
b = BigInt(7)
i = BigInt(5)
i_inplace = BigInt(0)
Base.GMP.MPZ.invert(i_inplace, a, b) == i
@test i_inplace == i
@test a == BigInt(3)
@test b == BigInt(7)
end

@testset "math ops returning BigFloat" begin
# operations that when applied to Int64 give Float64, should give BigFloat
@test typeof(exp(a)) == BigFloat
Expand Down

0 comments on commit 9eb202f

Please sign in to comment.