hunit-gui-0.1.2: tests/BarComputationsTests.hs
module BarComputationsTests (tests)
where
import Control.Monad
import Test.HUnit.Base
import Test.HUnit.Gui.BarComputations
tests :: Test
tests = test [ "normal case" ~: 66.66667 `assertApproxEqual` (barWidth (Counts 3 2 0 0) 100)
]
assertApproxEqual :: Double -> Double -> Assertion
assertApproxEqual expected actual =
unless (abs(expected - actual) < 0.001) (assertFailure msg)
where msg = "expected: " ++ show expected ++ "\nbut got: " ++ show actual