From 5d2e2ce99960ada6f41fb2952d5c1a5245727022 Mon Sep 17 00:00:00 2001 From: Vincent Hanquez Date: Tue, 12 May 2015 13:34:12 +0100 Subject: [PATCH] [Tests] factorise assertEq --- tests/BlockCipher.hs | 4 ---- tests/KAT_HMAC.hs | 4 ---- tests/Utils.hs | 7 +++++++ 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/tests/BlockCipher.hs b/tests/BlockCipher.hs index e8adecf..f7eb8c2 100644 --- a/tests/BlockCipher.hs +++ b/tests/BlockCipher.hs @@ -444,10 +444,6 @@ testBlockCipher kats cipher = testGroup (cipherName cipher) ++ testModes cipher ) -assertEq :: ByteString -> ByteString -> Bool -assertEq b1 b2 | b1 /= b2 = error ("b1: " ++ show b1 ++ " b2: " ++ show b2) - | otherwise = True - cipherMakeKey :: Cipher cipher => cipher -> ByteString -> Key cipher cipherMakeKey _ bs = Key bs diff --git a/tests/KAT_HMAC.hs b/tests/KAT_HMAC.hs index bcfb839..65ef6a4 100644 --- a/tests/KAT_HMAC.hs +++ b/tests/KAT_HMAC.hs @@ -160,10 +160,6 @@ macIncrementalTests = prop_inc1 _ (MacIncrementalList secret msgs result) = result `assertEq` HMAC.finalize (foldl' HMAC.update (HMAC.initialize secret) msgs) - assertEq a b - | a == b = True - | otherwise = False -- error ("expected: " ++ show a ++ " got: " ++ show b) - tests = testGroup "HMAC" [ testGroup "KATs" macTests , testGroup "properties" macIncrementalTests diff --git a/tests/Utils.hs b/tests/Utils.hs index f6072e8..a457f3d 100644 --- a/tests/Utils.hs +++ b/tests/Utils.hs @@ -52,3 +52,10 @@ splitB l b = else [ b ] +assertBytesEq :: ByteString -> ByteString -> Bool +assertBytesEq b1 b2 | b1 /= b2 = error ("expected: " ++ show b1 ++ " got: " ++ show b2) + | otherwise = True + +assertEq :: (Show a, Eq a) => a -> a -> Bool +assertEq b1 b2 | b1 /= b2 = error ("expected: " ++ show b1 ++ " got: " ++ show b2) + | otherwise = True