From 4a0bb47803be6be43b8bb5c62f302019a25f9fd1 Mon Sep 17 00:00:00 2001 From: Clint Adams Date: Wed, 25 Apr 2012 19:26:58 -0400 Subject: Encode multiple Armors into one ByteString. --- tests/data/msg1c.asc | 21 +++++++++++++++++++++ tests/suite.hs | 13 +++++++------ 2 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 tests/data/msg1c.asc (limited to 'tests') 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 @@ +-----BEGIN PGP MESSAGE----- +Version: OpenPrivacy 0.99 + +yDgBO22WxBHv7O8X7O/jygAEzol56iUKiXmV+XmpCtmpqQUKiQrFqclFqUDBovzS +vBSFjNSiVHsuAA== +=njUN +-----END PGP MESSAGE----- +-----BEGIN PGP MESSAGE----- +Version: OpenPrivacy 0.99 + +yDgBO22WxBHv7O8X7O/jygAEzol56iUKiXmV+XmpCtmpqQUKiQrFqclFqUDBovzS +vBSFjNSiVHsuAA== +=njUN +-----END PGP MESSAGE----- +-----BEGIN PGP MESSAGE----- +Version: OpenPrivacy 0.99 + +yDgBO22WxBHv7O8X7O/jygAEzol56iUKiXmV+XmpCtmpqQUKiQrFqclFqUDBovzS +vBSFjNSiVHsuAA== +=njUN +-----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 import Test.HUnit -import Codec.Encryption.OpenPGP.ASCIIArmor (armor, decode) +import Codec.Encryption.OpenPGP.ASCIIArmor (encode, decode) import Codec.Encryption.OpenPGP.ASCIIArmor.Types import Data.ByteString (ByteString) @@ -25,11 +25,11 @@ testArmorDecode fp targets = do where getPayload (Armor _ _ pl) = pl -testArmorEncode :: FilePath -> FilePath -> Assertion -testArmorEncode fp target = do - bs <- B.readFile $ "tests/data/" ++ fp +testArmorEncode :: [FilePath] -> FilePath -> Assertion +testArmorEncode fps target = do + bss <- mapM (\fp -> B.readFile $ "tests/data/" ++ fp) fps tbs <- B.readFile $ "tests/data/" ++ target - assertEqual ("literaldata") (armor (Armor ArmorMessage [("Version","OpenPrivacy 0.99")] bs)) tbs + assertEqual ("literaldata") (encode (map (\bs -> Armor ArmorMessage [("Version","OpenPrivacy 0.99")] bs) bss)) tbs tests = [ testGroup "CRC24" [ @@ -41,7 +41,8 @@ tests = [ testCase "Decode sample armor" (testArmorDecode "msg1.asc" ["msg1.gpg"]) , testCase "Decode sample armor with cruft" (testArmorDecode "msg1a.asc" ["msg1.gpg"]) , testCase "Decode multiple sample armors" (testArmorDecode "msg1b.asc" ["msg1.gpg","msg1.gpg","msg1.gpg"]) - , testCase "Encode sample armor" (testArmorEncode "msg1.gpg" "msg1.asc") + , testCase "Encode sample armor" (testArmorEncode ["msg1.gpg"] "msg1.asc") + , testCase "Encode multiple sample armors" (testArmorEncode ["msg1.gpg","msg1.gpg","msg1.gpg"] "msg1c.asc") ] ] -- cgit v1.2.3