Skip to content
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
7 changes: 5 additions & 2 deletions test/fixed.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,11 @@ end
end

@testset "testapprox" begin
for T in [Fixed{Int8,7}, Fixed{Int16,8}, Fixed{Int16,10}]
testapprox(T) # defined in ufixed.jl
@testset "approx $T" for T in [Fixed{Int8,7}, Fixed{Int16,8}, Fixed{Int16,10}]
xs = typemin(T):eps(T):typemax(T)-eps(T)
@test all(x -> x ≈ x + eps(T), xs)
@test all(x -> x + eps(T) ≈ x, xs)
@test !any(x -> x - eps(T) ≈ x + eps(T), xs)
end
end

Expand Down
16 changes: 5 additions & 11 deletions test/normed.jl
Original file line number Diff line number Diff line change
Expand Up @@ -230,18 +230,12 @@ end
end
end

function testapprox(::Type{T}) where {T}
for x = typemin(T):eps(T):typemax(T)-eps(T)
y = x+eps(T)
@test x ≈ y
@test y ≈ x
@test !(x ≈ y+eps(T))
end
end

@testset "approx" begin
for T in FixedPointNumbers.UF
testapprox(T)
@testset "approx $T" for T in FixedPointNumbers.UF
xs = typemin(T):eps(T):typemax(T)-eps(T)
@test all(x -> x ≈ x + eps(T), xs)
@test all(x -> x + eps(T) ≈ x, xs)
@test !any(x -> x - eps(T) ≈ x + eps(T), xs)
end
end

Expand Down