diff --git a/TestUtil.hs b/TestUtil.hs index 3db602c..ad14bf7 100644 --- a/TestUtil.hs +++ b/TestUtil.hs @@ -48,8 +48,11 @@ makeLiteralString str = A.Literal m (A.Array [A.Dimension (length str)] A.Byte) makeLiteralChar c = A.ArrayElemExpr $ A.Literal m A.Byte (A.ByteLiteral m [c] {-(show (fromEnum c))-}) -assertEqualCustom :: (Show a) => String -> (a -> a -> Bool) -> a -> a -> Assertion -assertEqualCustom preface cmp expected actual = +assertCompareCustom :: (Show a) => String -> (a -> a -> Bool) -> a -> a -> Assertion +assertCompareCustom preface cmp expected actual = unless (cmp actual expected) (assertFailure msg) where msg = (if null preface then "" else preface ++ "\n") ++ - "expected: " ++ show expected ++ "\n but got: " ++ show actual + "expected: " ++ show expected ++ "\n*** got: " ++ show actual + +assertNotEqual :: (Show a,Eq a) => String -> a -> a -> Assertion +assertNotEqual msg = assertCompareCustom msg (/=) diff --git a/UsageCheckTest.hs b/UsageCheckTest.hs index 481da1b..4cd737a 100644 --- a/UsageCheckTest.hs +++ b/UsageCheckTest.hs @@ -14,7 +14,7 @@ import Data.Ord --(it is an O(N^2) comparison), but thankfully it's only used during testing: assertEqualWR :: String -> UC.WrittenRead -> UC.WrittenRead -> Assertion assertEqualWR text exp act - = assertEqualCustom text inefficientEqual exp act + = assertCompareCustom text inefficientEqual exp act where --We can assume there are no duplicates, because getVars will remove duplicates, and --our expected values in tests should not have duplicate entries