From 30aef4fc00146ad1cc272f6f9a2440f99aba0659 Mon Sep 17 00:00:00 2001 From: Nathan Daly Date: Fri, 8 Dec 2023 18:07:04 -0700 Subject: [PATCH] Add fld/cld tests, but they still seem wrong, and abs/neg --- test/FixedDecimal.jl | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/FixedDecimal.jl b/test/FixedDecimal.jl index 1b9bd72..b0b0096 100644 --- a/test/FixedDecimal.jl +++ b/test/FixedDecimal.jl @@ -817,6 +817,7 @@ end end @testset "division" begin + # TODO(PR): Is this the expected value? @test typemax(FD2) / FD2(0.5) == FD2(-0.02) @test typemin(FD2) / FD2(0.5) == FD2(0) end @@ -828,6 +829,25 @@ end @test typemax(FD2) ÷ eps(FD2) == FD2(-1) @test typemin(FD2) ÷ eps(FD2) == FD2(0) end + + @testset "fld / cld" begin + # TODO(PR): Is this the expected value? + @test fld(typemax(FD2), FD2(0.5)) == FD2(-0.16) + @test fld(typemin(FD2), FD2(0.5)) == FD2(-0.84) + @test fld(typemax(FD2), eps(FD2)) == FD2(-1) + @test fld(typemin(FD2), eps(FD2)) == FD2(0) + + # TODO(PR): Is this the expected value? + @test cld(typemax(FD2), FD2(0.5)) == FD2(0.84) + @test cld(typemin(FD2), FD2(0.5)) == FD2(0.16) + @test cld(typemax(FD2), eps(FD2)) == FD2(-1) + @test cld(typemin(FD2), eps(FD2)) == FD2(0) + end + + @testset "abs / neg" begin + @test abs(typemin(FD2)) == typemin(FD2) + @test -(typemin(FD2)) == typemin(FD2) + end end @testset "isinteger" begin