From ea00b231585d2307e4b10ba846f83943f0fe68d8 Mon Sep 17 00:00:00 2001 From: Petr Vana Date: Wed, 25 May 2022 19:59:30 +0200 Subject: [PATCH] Imrpove test coverage + use zero() --- src/intervals/functions.jl | 2 +- test/interval_tests/numeric.jl | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/intervals/functions.jl b/src/intervals/functions.jl index be3de79c2..cc9d6f2b1 100644 --- a/src/intervals/functions.jl +++ b/src/intervals/functions.jl @@ -378,7 +378,7 @@ end Calculate `x mod y` where `x` is an interval and `y` is a positive divisor. """ function mod(x::Interval, y::Real) - @assert y > 0 "modulo is currently implemented only for a positive divisor." + @assert y > zero(y) "modulo is currently implemented only for a positive divisor." division = x / y fl = floor(division) fl.lo < fl.hi ? Interval(zero(y), y) : y * (division - fl) diff --git a/test/interval_tests/numeric.jl b/test/interval_tests/numeric.jl index d23b679e1..3d88a91a0 100644 --- a/test/interval_tests/numeric.jl +++ b/test/interval_tests/numeric.jl @@ -458,4 +458,6 @@ end @test mod(x, 2) == mod(x, 2.0) == 0..2 @test mod(x, 2.5) == 0..2.5 @test mod(x, 0.5) == 0..0.5 + + @test_throws AssertionError mod(x, -1) end