diff options
author | Benjamin Barenblat <bbaren@google.com> | 2018-03-23 18:34:42 -0400 |
---|---|---|
committer | Benjamin Barenblat <bbaren@google.com> | 2018-03-23 18:34:42 -0400 |
commit | 0ed87caa3481cbb6f8c2e809e5ec7df6f6245406 (patch) | |
tree | e7267e4b7996920577aa556ff7a67a312a271216 /tests | |
parent | 3e898da300395bc3e63780b8d27a97fd4a9c375c (diff) |
Data.Digest: Reify hash algorithms
Eliminate the functional interface for hashing. Hashing now occurs
exclusively through the `hash` function, which accepts a
`Data.Digest.Algorithm`. This makes btls somewhat less extensible, but
it’s the most elegant way to support HMACs.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Data/Digest/Md5Tests.hs | 6 | ||||
-rw-r--r-- | tests/Data/Digest/Sha1Tests.hs | 6 | ||||
-rw-r--r-- | tests/Data/Digest/Sha2Tests.hs | 12 | ||||
-rw-r--r-- | tests/Data/DigestTests.hs | 18 | ||||
-rw-r--r-- | tests/Tests.hs | 13 |
5 files changed, 32 insertions, 23 deletions
diff --git a/tests/Data/Digest/Md5Tests.hs b/tests/Data/Digest/Md5Tests.hs index f7f62a7..bbc5fba 100644 --- a/tests/Data/Digest/Md5Tests.hs +++ b/tests/Data/Digest/Md5Tests.hs @@ -10,12 +10,12 @@ import Test.Tasty.SmallCheck (testProperty) import Data.Digest.HashTests (tableTestCase, testAgainstCoreutils, testAgainstOpenssl) -import Data.Digest.Md5 +import Data.Digest (hash, md5) tests :: TestTree tests = testGroup - "Data.Digest.Md5" + "MD5" [ testRfcExamples , testGoExamples , testCoreutilsConformance @@ -106,4 +106,4 @@ testOpensslConformance = -- Convenience function. -md5sum = show . md5 . ByteString.Lazy.fromStrict +md5sum = show . hash md5 . ByteString.Lazy.fromStrict diff --git a/tests/Data/Digest/Sha1Tests.hs b/tests/Data/Digest/Sha1Tests.hs index cd1f1c6..63c774d 100644 --- a/tests/Data/Digest/Sha1Tests.hs +++ b/tests/Data/Digest/Sha1Tests.hs @@ -11,12 +11,12 @@ import Test.Tasty.SmallCheck (testProperty) import Data.Digest.HashTests (tableTestCase, testAgainstCoreutils, testAgainstOpenssl) -import Data.Digest.Sha1 +import Data.Digest (hash, sha1) tests :: TestTree tests = testGroup - "Data.Digest.Sha1" + "SHA-1" [ testNistExamples , testGoExamples , testCoreutilsConformance @@ -107,4 +107,4 @@ testOpensslConformance = -- Convenience function. -sha1sum = show . sha1 . ByteString.Lazy.fromStrict +sha1sum = show . hash sha1 . ByteString.Lazy.fromStrict diff --git a/tests/Data/Digest/Sha2Tests.hs b/tests/Data/Digest/Sha2Tests.hs index b1faf27..1df607b 100644 --- a/tests/Data/Digest/Sha2Tests.hs +++ b/tests/Data/Digest/Sha2Tests.hs @@ -11,12 +11,12 @@ import Test.Tasty.SmallCheck (testProperty) import Data.Digest.HashTests (tableTestCase, testAgainstCoreutils, testAgainstOpenssl) -import Data.Digest.Sha2 +import Data.Digest (hash, sha224, sha256, sha384, sha512) tests :: TestTree tests = testGroup - "Data.Digest.Sha2" + "SHA-2" [ testNistExamples , testGoExamples , testCoreutilsConformance @@ -497,10 +497,10 @@ testOpensslConformance = -- Convenience functions. -sha224sum = show . sha224 . ByteString.Lazy.fromStrict +sha224sum = show . hash sha224 . ByteString.Lazy.fromStrict -sha256sum = show . sha256 . ByteString.Lazy.fromStrict +sha256sum = show . hash sha256 . ByteString.Lazy.fromStrict -sha384sum = show . sha384 . ByteString.Lazy.fromStrict +sha384sum = show . hash sha384 . ByteString.Lazy.fromStrict -sha512sum = show . sha512 . ByteString.Lazy.fromStrict +sha512sum = show . hash sha512 . ByteString.Lazy.fromStrict diff --git a/tests/Data/DigestTests.hs b/tests/Data/DigestTests.hs new file mode 100644 index 0000000..e1e67b4 --- /dev/null +++ b/tests/Data/DigestTests.hs @@ -0,0 +1,18 @@ +module Data.DigestTests + ( tests + ) where + +import Test.Tasty (TestTree, testGroup) + +import qualified Data.Digest.Md5Tests +import qualified Data.Digest.Sha1Tests +import qualified Data.Digest.Sha2Tests + +tests :: TestTree +tests = + testGroup + "Data.Digest" + [ Data.Digest.Md5Tests.tests + , Data.Digest.Sha1Tests.tests + , Data.Digest.Sha2Tests.tests + ] diff --git a/tests/Tests.hs b/tests/Tests.hs index caec20a..565ab16 100644 --- a/tests/Tests.hs +++ b/tests/Tests.hs @@ -4,16 +4,7 @@ module Main import Test.Tasty (defaultMain, testGroup) -import qualified Data.Digest.Md5Tests -import qualified Data.Digest.Sha1Tests -import qualified Data.Digest.Sha2Tests +import qualified Data.DigestTests main :: IO () -main = - defaultMain $ - testGroup - "btls" - [ Data.Digest.Md5Tests.tests - , Data.Digest.Sha1Tests.tests - , Data.Digest.Sha2Tests.tests - ] +main = defaultMain $ testGroup "btls" [Data.DigestTests.tests] |