File tree Expand file tree Collapse file tree 2 files changed +51
-3
lines changed Expand file tree Collapse file tree 2 files changed +51
-3
lines changed Original file line number Diff line number Diff line change
1
+ module Main where
2
+
3
+ import Test.Framework
4
+ import Test.Framework.Providers.QuickCheck2 (testProperty )
1
5
import Test.MD5
6
+ import Data.Digest.Pure.MD5
7
+ import Data.Char (isSpace )
8
+ import Data.ByteString.Lazy (toStrict , ByteString )
9
+ import qualified Data.Binary as B
10
+ import qualified Data.Serialize as S
11
+ import Hexdump
12
+
13
+ main :: IO ()
14
+ main = defaultMain
15
+ [ testGroup " MD5 functional correctness tests" base_tests
16
+ , testGroup " Serialization order correctness tests" serialization_tests
17
+ ]
18
+
19
+ -- | Use the crypto-api-tests, piddly as they are, to give evidence of
20
+ -- functional correctness.
21
+ base_tests :: [Test ]
22
+ base_tests = makeMD5Tests (undefined :: MD5Digest )
2
23
3
- main = test
24
+ -- | Ensure the output of `show`, `Serialize`, `Binary`, and `md5DigestBytes`
25
+ -- are all consistent.
26
+ serialization_tests :: [Test ]
27
+ serialization_tests =
28
+ [ testProperty " show == simple_hex . Serialize.encode"
29
+ (\ bs -> let d = hsh bs in show d == filter (not . isSpace) (simpleHex (S. encode d)))
30
+ , testProperty " Serialize.encode == toStrict . Binary.encode"
31
+ (\ bs -> let d = hsh bs in toStrict (B. encode d) == S. encode d)
32
+ , testProperty " Serialize.encode == md5DigestBytes"
33
+ (\ bs -> let d = hsh bs in S. encode d == md5DigestBytes d)
34
+ ]
35
+ where
36
+ hsh = hash :: ByteString -> MD5Digest
Original file line number Diff line number Diff line change @@ -10,8 +10,8 @@ synopsis: A Haskell-only implementation of the MD5 digest (hash) algorithm.
10
10
category : Data, Cryptography
11
11
stability : stable
12
12
build-type : Simple
13
- cabal-version : >= 1.6
14
- tested-with : GHC == 6.12.1
13
+ cabal-version : >= 1.10
14
+ tested-with : GHC == 7.10.3
15
15
extra-source-files : Test/MD5.hs
16
16
17
17
flag test
@@ -26,6 +26,21 @@ Library
26
26
if arch(i386) || arch(x86_64)
27
27
cpp-options : -DFastWordExtract
28
28
29
+ Test-Suite MD5Tests
30
+ type : exitcode-stdio-1.0
31
+ default-language : Haskell2010
32
+ build-depends : base >= 4.6 && < 5 ,
33
+ pureMD5,
34
+ crypto-api-tests,
35
+ QuickCheck,
36
+ test-framework >= 0.8 ,
37
+ test-framework-quickcheck2,
38
+ binary, cereal, pretty-hex,
39
+ bytestring
40
+ ghc-options : -Wall
41
+ hs-source-dirs : Test
42
+ main-is : main.hs
43
+
29
44
source-repository head
30
45
type : git
31
46
location : https://github.com/TomMD/pureMD5
You can’t perform that action at this time.
0 commit comments