diff options
author | Clint Adams <clint@debian.org> | 2012-04-25 19:26:58 -0400 |
---|---|---|
committer | Clint Adams <clint@debian.org> | 2012-04-25 19:27:26 -0400 |
commit | 4a0bb47803be6be43b8bb5c62f302019a25f9fd1 (patch) | |
tree | 53c0f2ae494136395401d6dc73f4409cba4f0637 /tests | |
parent | f06c3f713f99c9ea09a76728ffce2c6e1c957070 (diff) |
Encode multiple Armors into one ByteString.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/data/msg1c.asc | 21 | ||||
-rw-r--r-- | tests/suite.hs | 13 |
2 files changed, 28 insertions, 6 deletions
diff --git a/tests/data/msg1c.asc b/tests/data/msg1c.asc new file mode 100644 index 0000000..c7ac785 --- /dev/null +++ b/tests/data/msg1c.asc | |||
@@ -0,0 +1,21 @@ | |||
1 | -----BEGIN PGP MESSAGE----- | ||
2 | Version: OpenPrivacy 0.99 | ||
3 | |||
4 | yDgBO22WxBHv7O8X7O/jygAEzol56iUKiXmV+XmpCtmpqQUKiQrFqclFqUDBovzS | ||
5 | vBSFjNSiVHsuAA== | ||
6 | =njUN | ||
7 | -----END PGP MESSAGE----- | ||
8 | -----BEGIN PGP MESSAGE----- | ||
9 | Version: OpenPrivacy 0.99 | ||
10 | |||
11 | yDgBO22WxBHv7O8X7O/jygAEzol56iUKiXmV+XmpCtmpqQUKiQrFqclFqUDBovzS | ||
12 | vBSFjNSiVHsuAA== | ||
13 | =njUN | ||
14 | -----END PGP MESSAGE----- | ||
15 | -----BEGIN PGP MESSAGE----- | ||
16 | Version: OpenPrivacy 0.99 | ||
17 | |||
18 | yDgBO22WxBHv7O8X7O/jygAEzol56iUKiXmV+XmpCtmpqQUKiQrFqclFqUDBovzS | ||
19 | vBSFjNSiVHsuAA== | ||
20 | =njUN | ||
21 | -----END PGP MESSAGE----- | ||
diff --git a/tests/suite.hs b/tests/suite.hs index 45a2fb2..a843664 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 (armor, decode) | 6 | import Codec.Encryption.OpenPGP.ASCIIArmor (encode, decode) |
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) |
@@ -25,11 +25,11 @@ testArmorDecode fp targets = do | |||
25 | where | 25 | where |
26 | getPayload (Armor _ _ pl) = pl | 26 | getPayload (Armor _ _ pl) = pl |
27 | 27 | ||
28 | testArmorEncode :: FilePath -> FilePath -> Assertion | 28 | testArmorEncode :: [FilePath] -> FilePath -> Assertion |
29 | testArmorEncode fp target = do | 29 | testArmorEncode fps target = do |
30 | bs <- B.readFile $ "tests/data/" ++ fp | 30 | bss <- mapM (\fp -> B.readFile $ "tests/data/" ++ fp) fps |
31 | tbs <- B.readFile $ "tests/data/" ++ target | 31 | tbs <- B.readFile $ "tests/data/" ++ target |
32 | assertEqual ("literaldata") (armor (Armor ArmorMessage [("Version","OpenPrivacy 0.99")] bs)) tbs | 32 | assertEqual ("literaldata") (encode (map (\bs -> Armor ArmorMessage [("Version","OpenPrivacy 0.99")] bs) bss)) tbs |
33 | 33 | ||
34 | tests = [ | 34 | tests = [ |
35 | testGroup "CRC24" [ | 35 | testGroup "CRC24" [ |
@@ -41,7 +41,8 @@ tests = [ | |||
41 | testCase "Decode sample armor" (testArmorDecode "msg1.asc" ["msg1.gpg"]) | 41 | testCase "Decode sample armor" (testArmorDecode "msg1.asc" ["msg1.gpg"]) |
42 | , testCase "Decode sample armor with cruft" (testArmorDecode "msg1a.asc" ["msg1.gpg"]) | 42 | , 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"]) | 43 | , testCase "Decode multiple sample armors" (testArmorDecode "msg1b.asc" ["msg1.gpg","msg1.gpg","msg1.gpg"]) |
44 | , testCase "Encode sample armor" (testArmorEncode "msg1.gpg" "msg1.asc") | 44 | , testCase "Encode sample armor" (testArmorEncode ["msg1.gpg"] "msg1.asc") |
45 | , testCase "Encode multiple sample armors" (testArmorEncode ["msg1.gpg","msg1.gpg","msg1.gpg"] "msg1c.asc") | ||
45 | ] | 46 | ] |
46 | ] | 47 | ] |
47 | 48 | ||