diff options
Diffstat (limited to 'tests/suite.hs')
-rw-r--r-- | tests/suite.hs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/tests/suite.hs b/tests/suite.hs index a843664..6fdd816 100644 --- a/tests/suite.hs +++ b/tests/suite.hs | |||
@@ -3,7 +3,7 @@ import Test.Framework.Providers.HUnit | |||
3 | 3 | ||
4 | import Test.HUnit | 4 | import Test.HUnit |
5 | 5 | ||
6 | import Codec.Encryption.OpenPGP.ASCIIArmor (encode, decode) | 6 | import Codec.Encryption.OpenPGP.ASCIIArmor (encode, decode, multipartMerge) |
7 | import Codec.Encryption.OpenPGP.ASCIIArmor.Types | 7 | import Codec.Encryption.OpenPGP.ASCIIArmor.Types |
8 | 8 | ||
9 | import Data.ByteString (ByteString) | 9 | import Data.ByteString (ByteString) |
@@ -21,7 +21,17 @@ testArmorDecode fp targets = do | |||
21 | tbss <- mapM (\target -> B.readFile $ "tests/data/" ++ target) targets | 21 | tbss <- mapM (\target -> B.readFile $ "tests/data/" ++ target) targets |
22 | case decode bs of | 22 | case decode bs of |
23 | Left e -> assertFailure $ "Decode failed (" ++ e ++ ") on " ++ fp | 23 | Left e -> assertFailure $ "Decode failed (" ++ e ++ ") on " ++ fp |
24 | Right as -> do assertEqual ("for " ++ fp) tbss (map getPayload as) | 24 | Right as -> assertEqual ("for " ++ fp) tbss (map getPayload as) |
25 | where | ||
26 | getPayload (Armor _ _ pl) = pl | ||
27 | |||
28 | testArmorMultipartDecode :: FilePath -> FilePath -> Assertion | ||
29 | testArmorMultipartDecode fp target = do | ||
30 | bs <- B.readFile $ "tests/data/" ++ fp | ||
31 | tbs <- B.readFile $ "tests/data/" ++ target | ||
32 | case decode bs of | ||
33 | Left e -> assertFailure $ "Decode failed (" ++ e ++ ") on " ++ fp | ||
34 | Right as -> assertEqual ("for " ++ fp) tbs (getPayload (multipartMerge as)) | ||
25 | where | 35 | where |
26 | getPayload (Armor _ _ pl) = pl | 36 | getPayload (Armor _ _ pl) = pl |
27 | 37 | ||
@@ -41,6 +51,7 @@ tests = [ | |||
41 | testCase "Decode sample armor" (testArmorDecode "msg1.asc" ["msg1.gpg"]) | 51 | testCase "Decode sample armor" (testArmorDecode "msg1.asc" ["msg1.gpg"]) |
42 | , testCase "Decode sample armor with cruft" (testArmorDecode "msg1a.asc" ["msg1.gpg"]) | 52 | , testCase "Decode sample armor with cruft" (testArmorDecode "msg1a.asc" ["msg1.gpg"]) |
43 | , testCase "Decode multiple sample armors" (testArmorDecode "msg1b.asc" ["msg1.gpg","msg1.gpg","msg1.gpg"]) | 53 | , testCase "Decode multiple sample armors" (testArmorDecode "msg1b.asc" ["msg1.gpg","msg1.gpg","msg1.gpg"]) |
54 | , testCase "Decode multi-part armor" (testArmorMultipartDecode "msg2.asc" "msg2.pgp") | ||
44 | , testCase "Encode sample armor" (testArmorEncode ["msg1.gpg"] "msg1.asc") | 55 | , testCase "Encode sample armor" (testArmorEncode ["msg1.gpg"] "msg1.asc") |
45 | , testCase "Encode multiple sample armors" (testArmorEncode ["msg1.gpg","msg1.gpg","msg1.gpg"] "msg1c.asc") | 56 | , testCase "Encode multiple sample armors" (testArmorEncode ["msg1.gpg","msg1.gpg","msg1.gpg"] "msg1c.asc") |
46 | ] | 57 | ] |