Skip to content

Increase code coverage #2063

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions test/Nemo-test.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
testlist = [
# Aqua.jl
"Aqua.jl",
# Julia extensions
"julia/Float-test.jl",
"julia/Integer-test.jl",
"julia/Rational-test.jl",
# Fields-test.jl
"flint/fmpq-test.jl",
"flint/gfp-test.jl",
Expand Down
14 changes: 14 additions & 0 deletions test/julia/Float-test.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@testset "BigFloat manipulation" begin
a = BigFloat(5) / BigFloat(3)
b = BigFloat(1) / BigFloat(7)
def_prec = precision(BigFloat)
new_prec = 127

@test precision(a) == def_prec
setprecision!(a, new_prec)
@test precision(a) == new_prec
setprecision!(b, new_prec)
@test precision(b) == new_prec
mul!(a, a, b) # Does not work with a *= b
@test precision(a) == new_prec
end
28 changes: 28 additions & 0 deletions test/julia/Integer-test.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
@testset "Prime wrappers" begin
a = UInt8(3)
@test is_prime(a)
b = next_prime(a)
@test b == UInt8(5)
@test typeof(b) == UInt8
end

@testset "UInt valuation" begin
for (a, b) in [(1, 2), (4, 2), (9, 3), (12, 2), (12, 3), (12, 4), (12, 5)]
@test valuation(UInt(a), UInt(b)) == valuation(a, b)
end
end

@testset "Integer fits" begin
@test fits(Int, typemin(Int))
@test fits(Int, typemax(Int))
@test !fits(Int, typemax(UInt))
@test fits(Int, typemin(UInt))
@test fits(Int, UInt(typemax(Int)))
end

@testset "Integer clog" begin
@test clog(7, 2) == 3
@test clog(8, 2) == 3
@test clog(25, 5) == 2
@test clog(27, 5) == 3
end
15 changes: 15 additions & 0 deletions test/julia/Rational-test.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@testset "Rational in-place operations" begin
a = 1 // 3
b = 3 // 2
q = 0 // 1
n = 0
d = 0

q = divexact!(q, a, b)
n = numerator!(n, q)
d = denominator!(d, q)

@test q == 2 // 9 && typeof(q) == Rational{Int}
@test n == 2 && typeof(n) == Int
@test d == 9 && typeof(d) == Int
end
Loading