4 import Control.Monad (unless)
10 -- | An HUnit assertion that wraps the almost_equals function. Stolen
11 -- from the definition of assertEqual in Test/HUnit/Base.hs.
12 assertAlmostEqual :: String -> Double -> Double -> Assertion
13 assertAlmostEqual preface expected actual =
14 unless (actual ~= expected) (assertFailure msg)
15 where msg = (if null preface then "" else preface ++ "\n") ++
16 "expected: " ++ show expected ++ "\n but got: " ++ show actual
19 -- | An HUnit assertion that wraps the is_close function. Stolen
20 -- from the definition of assertEqual in Test/HUnit/Base.hs.
21 assertClose :: String -> Point -> Point -> Assertion
22 assertClose preface expected actual =
23 unless (actual `is_close` expected) (assertFailure msg)
24 where msg = (if null preface then "" else preface ++ "\n") ++
25 "expected: " ++ show expected ++ "\n but got: " ++ show actual