summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorClint Adams <clint@debian.org>2012-07-27 23:48:27 -0400
committerClint Adams <clint@debian.org>2012-07-27 23:48:27 -0400
commitc708dc4b1d84bc85c52c5c3255f65c62a67ee039 (patch)
tree59dcc5dff95c2803e531e009bd411e85405ac5ee /tests
parent3a9f6d91f4b1e36d92ea18237ae8caf1bb639203 (diff)
Make -Wall-clean and build with -Wall.
Diffstat (limited to 'tests')
-rw-r--r--tests/suite.hs12
1 files changed, 10 insertions, 2 deletions
diff --git a/tests/suite.hs b/tests/suite.hs
index ffcbc17..5ad3d05 100644
--- a/tests/suite.hs
+++ b/tests/suite.hs
@@ -1,7 +1,7 @@
1import Test.Framework (defaultMain, testGroup) 1import Test.Framework (defaultMain, testGroup, Test)
2import Test.Framework.Providers.HUnit 2import Test.Framework.Providers.HUnit
3 3
4import Test.HUnit 4import Test.HUnit (Assertion, assertEqual, assertFailure)
5 5
6import Codec.Encryption.OpenPGP.ASCIIArmor (decode, decodeLazy, encode, encodeLazy, multipartMerge) 6import Codec.Encryption.OpenPGP.ASCIIArmor (decode, decodeLazy, encode, encodeLazy, multipartMerge)
7import Codec.Encryption.OpenPGP.ASCIIArmor.Types 7import Codec.Encryption.OpenPGP.ASCIIArmor.Types
@@ -27,6 +27,7 @@ testArmorDecode fp targets = do
27 Right as -> assertEqual ("for " ++ fp) tbss (map getPayload as) 27 Right as -> assertEqual ("for " ++ fp) tbss (map getPayload as)
28 where 28 where
29 getPayload (Armor _ _ pl) = pl 29 getPayload (Armor _ _ pl) = pl
30 getPayload _ = error "This should not happen."
30 31
31testArmorMultipartDecode :: FilePath -> FilePath -> Assertion 32testArmorMultipartDecode :: FilePath -> FilePath -> Assertion
32testArmorMultipartDecode fp target = do 33testArmorMultipartDecode fp target = do
@@ -37,6 +38,7 @@ testArmorMultipartDecode fp target = do
37 Right as -> assertEqual ("for " ++ fp) tbs (getPayload (multipartMerge as)) 38 Right as -> assertEqual ("for " ++ fp) tbs (getPayload (multipartMerge as))
38 where 39 where
39 getPayload (Armor _ _ pl) = pl 40 getPayload (Armor _ _ pl) = pl
41 getPayload _ = error "This should not happen."
40 42
41testClearsignedDecodeBody :: FilePath -> FilePath -> Assertion 43testClearsignedDecodeBody :: FilePath -> FilePath -> Assertion
42testClearsignedDecodeBody fp target = do 44testClearsignedDecodeBody fp target = do
@@ -45,8 +47,10 @@ testClearsignedDecodeBody fp target = do
45 case decodeLazy bs of 47 case decodeLazy bs of
46 Left e -> assertFailure $ "Decode failed (" ++ e ++ ") on " ++ fp 48 Left e -> assertFailure $ "Decode failed (" ++ e ++ ") on " ++ fp
47 Right [a] -> assertEqual ("for " ++ fp) (convertEndings tbs) (getBody a) 49 Right [a] -> assertEqual ("for " ++ fp) (convertEndings tbs) (getBody a)
50 _ -> assertFailure "This shouldn't happen."
48 where 51 where
49 getBody (ClearSigned _ txt _) = txt 52 getBody (ClearSigned _ txt _) = txt
53 getBody _ = error "This should not happen."
50 convertEndings = crlfUnlinesLazy . BLC8.lines 54 convertEndings = crlfUnlinesLazy . BLC8.lines
51 55
52testClearsignedDecodeSig :: FilePath -> FilePath -> Assertion 56testClearsignedDecodeSig :: FilePath -> FilePath -> Assertion
@@ -56,8 +60,10 @@ testClearsignedDecodeSig fp target = do
56 case decodeLazy bs of 60 case decodeLazy bs of
57 Left e -> assertFailure $ "Decode failed (" ++ e ++ ") on " ++ fp 61 Left e -> assertFailure $ "Decode failed (" ++ e ++ ") on " ++ fp
58 Right [a] -> assertEqual ("for " ++ fp) tbs (getSig a) 62 Right [a] -> assertEqual ("for " ++ fp) tbs (getSig a)
63 _ -> assertFailure "This shouldn't happen."
59 where 64 where
60 getSig (ClearSigned _ _ (Armor _ _ sig)) = sig 65 getSig (ClearSigned _ _ (Armor _ _ sig)) = sig
66 getSig _ = error "This should not happen."
61 67
62testArmorEncode :: [FilePath] -> FilePath -> Assertion 68testArmorEncode :: [FilePath] -> FilePath -> Assertion
63testArmorEncode fps target = do 69testArmorEncode fps target = do
@@ -83,6 +89,7 @@ testStrictEncode fp = do
83 let fakearmors = [Armor ArmorMessage [("Version","OpenPrivacy 0.99")] bs, ClearSigned [("Hash","SHA1")] bs (Armor ArmorSignature [("Version","OpenPrivacy 0.99")] bs)] 89 let fakearmors = [Armor ArmorMessage [("Version","OpenPrivacy 0.99")] bs, ClearSigned [("Hash","SHA1")] bs (Armor ArmorSignature [("Version","OpenPrivacy 0.99")] bs)]
84 assertEqual ("strict encode") (encodeLazy fakearmors) (BL.fromChunks [(encode fakearmors)]) 90 assertEqual ("strict encode") (encodeLazy fakearmors) (BL.fromChunks [(encode fakearmors)])
85 91
92tests :: [Test]
86tests = [ 93tests = [
87 testGroup "CRC24" [ 94 testGroup "CRC24" [
88 testCase "CRC24: A" (testCRC24 (BC8.pack "A") 16680698) 95 testCase "CRC24: A" (testCRC24 (BC8.pack "A") 16680698)
@@ -105,4 +112,5 @@ tests = [
105 ] 112 ]
106 ] 113 ]
107 114
115main :: IO ()
108main = defaultMain tests 116main = defaultMain tests