diff options
Diffstat (limited to 'tests/suite.hs')
-rw-r--r-- | tests/suite.hs | 126 |
1 files changed, 126 insertions, 0 deletions
diff --git a/tests/suite.hs b/tests/suite.hs new file mode 100644 index 0000000..cd02bff --- /dev/null +++ b/tests/suite.hs | |||
@@ -0,0 +1,126 @@ | |||
1 | import Test.Framework (defaultMain, testGroup, Test) | ||
2 | import Test.Framework.Providers.HUnit | ||
3 | import Test.Framework.Providers.QuickCheck2 | ||
4 | import Test.QuickCheck () | ||
5 | import Test.HUnit hiding (Test) | ||
6 | |||
7 | import Data.Word | ||
8 | import Data.Binary | ||
9 | import qualified Data.OpenPGP as OpenPGP | ||
10 | import qualified Data.ByteString.Lazy as LZ | ||
11 | |||
12 | testSerialization :: FilePath -> Assertion | ||
13 | testSerialization fp = do | ||
14 | bs <- LZ.readFile $ "tests/data/" ++ fp | ||
15 | nullShield "First" (decode bs) (\firstpass -> | ||
16 | nullShield "Second" (decode $ encode firstpass) (\secondpass -> | ||
17 | assertEqual ("for " ++ fp) firstpass secondpass | ||
18 | ) | ||
19 | ) | ||
20 | where | ||
21 | nullShield pass (OpenPGP.Message []) _ = | ||
22 | assertFailure $ pass ++ " pass of " ++ fp ++ " decoded to nothing." | ||
23 | nullShield _ m f = f m | ||
24 | |||
25 | prop_s2k_count :: Word8 -> Bool | ||
26 | prop_s2k_count c = | ||
27 | c == OpenPGP.encode_s2k_count (OpenPGP.decode_s2k_count c) | ||
28 | |||
29 | tests :: [Test] | ||
30 | tests = | ||
31 | [ | ||
32 | testGroup "Serialization group" [ | ||
33 | testCase "000001-006.public_key" (testSerialization "000001-006.public_key"), | ||
34 | testCase "000002-013.user_id" (testSerialization "000002-013.user_id"), | ||
35 | --testCase "000003-002.sig" (testSerialization "000003-002.sig"), | ||
36 | --testCase "000004-012.ring_trust" (testSerialization "000004-012.ring_trust"), | ||
37 | --testCase "000005-002.sig" (testSerialization "000005-002.sig"), | ||
38 | --testCase "000006-012.ring_trust" (testSerialization "000006-012.ring_trust"), | ||
39 | --testCase "000007-002.sig" (testSerialization "000007-002.sig"), | ||
40 | --testCase "000008-012.ring_trust" (testSerialization "000008-012.ring_trust"), | ||
41 | -- Issue #11 -- testCase "000009-002.sig" (testSerialization "000009-002.sig"), | ||
42 | --testCase "000010-012.ring_trust" (testSerialization "000010-012.ring_trust"), | ||
43 | -- Issue #11 -- testCase "000011-002.sig" (testSerialization "000011-002.sig"), | ||
44 | --testCase "000012-012.ring_trust" (testSerialization "000012-012.ring_trust"), | ||
45 | --testCase "000013-014.public_subkey" (testSerialization "000013-014.public_subkey"), | ||
46 | --testCase "000014-002.sig" (testSerialization "000014-002.sig"), | ||
47 | --testCase "000015-012.ring_trust" (testSerialization "000015-012.ring_trust"), | ||
48 | testCase "000016-006.public_key" (testSerialization "000016-006.public_key"), | ||
49 | --testCase "000017-002.sig" (testSerialization "000017-002.sig"), | ||
50 | --testCase "000018-012.ring_trust" (testSerialization "000018-012.ring_trust"), | ||
51 | testCase "000019-013.user_id" (testSerialization "000019-013.user_id"), | ||
52 | --testCase "000020-002.sig" (testSerialization "000020-002.sig"), | ||
53 | --testCase "000021-012.ring_trust" (testSerialization "000021-012.ring_trust"), | ||
54 | -- Issue #11 -- testCase "000022-002.sig" (testSerialization "000022-002.sig"), | ||
55 | --testCase "000023-012.ring_trust" (testSerialization "000023-012.ring_trust"), | ||
56 | --testCase "000024-014.public_subkey" (testSerialization "000024-014.public_subkey"), | ||
57 | --testCase "000025-002.sig" (testSerialization "000025-002.sig"), | ||
58 | --testCase "000026-012.ring_trust" (testSerialization "000026-012.ring_trust"), | ||
59 | testCase "000027-006.public_key" (testSerialization "000027-006.public_key"), | ||
60 | --testCase "000028-002.sig" (testSerialization "000028-002.sig"), | ||
61 | --testCase "000029-012.ring_trust" (testSerialization "000029-012.ring_trust"), | ||
62 | testCase "000030-013.user_id" (testSerialization "000030-013.user_id"), | ||
63 | --testCase "000031-002.sig" (testSerialization "000031-002.sig"), | ||
64 | --testCase "000032-012.ring_trust" (testSerialization "000032-012.ring_trust"), | ||
65 | -- Issue #11 -- testCase "000033-002.sig" (testSerialization "000033-002.sig"), | ||
66 | --testCase "000034-012.ring_trust" (testSerialization "000034-012.ring_trust"), | ||
67 | testCase "000035-006.public_key" (testSerialization "000035-006.public_key"), | ||
68 | testCase "000036-013.user_id" (testSerialization "000036-013.user_id"), | ||
69 | --testCase "000037-002.sig" (testSerialization "000037-002.sig"), | ||
70 | --testCase "000038-012.ring_trust" (testSerialization "000038-012.ring_trust"), | ||
71 | -- Issue #11 -- testCase "000039-002.sig" (testSerialization "000039-002.sig"), | ||
72 | --testCase "000040-012.ring_trust" (testSerialization "000040-012.ring_trust"), | ||
73 | --testCase "000041-017.attribute" (testSerialization "000041-017.attribute"), | ||
74 | --testCase "000042-002.sig" (testSerialization "000042-002.sig"), | ||
75 | --testCase "000043-012.ring_trust" (testSerialization "000043-012.ring_trust"), | ||
76 | --testCase "000044-014.public_subkey" (testSerialization "000044-014.public_subkey"), | ||
77 | --testCase "000045-002.sig" (testSerialization "000045-002.sig"), | ||
78 | --testCase "000046-012.ring_trust" (testSerialization "000046-012.ring_trust"), | ||
79 | testCase "000047-005.secret_key" (testSerialization "000047-005.secret_key"), | ||
80 | testCase "000048-013.user_id" (testSerialization "000048-013.user_id"), | ||
81 | --testCase "000049-002.sig" (testSerialization "000049-002.sig"), | ||
82 | --testCase "000050-012.ring_trust" (testSerialization "000050-012.ring_trust"), | ||
83 | --testCase "000051-007.secret_subkey" (testSerialization "000051-007.secret_subkey"), | ||
84 | --testCase "000052-002.sig" (testSerialization "000052-002.sig"), | ||
85 | --testCase "000053-012.ring_trust" (testSerialization "000053-012.ring_trust"), | ||
86 | testCase "000054-005.secret_key" (testSerialization "000054-005.secret_key"), | ||
87 | --testCase "000055-002.sig" (testSerialization "000055-002.sig"), | ||
88 | --testCase "000056-012.ring_trust" (testSerialization "000056-012.ring_trust"), | ||
89 | testCase "000057-013.user_id" (testSerialization "000057-013.user_id"), | ||
90 | --testCase "000058-002.sig" (testSerialization "000058-002.sig"), | ||
91 | --testCase "000059-012.ring_trust" (testSerialization "000059-012.ring_trust"), | ||
92 | --testCase "000060-007.secret_subkey" (testSerialization "000060-007.secret_subkey"), | ||
93 | --testCase "000061-002.sig" (testSerialization "000061-002.sig"), | ||
94 | --testCase "000062-012.ring_trust" (testSerialization "000062-012.ring_trust"), | ||
95 | testCase "000063-005.secret_key" (testSerialization "000063-005.secret_key"), | ||
96 | --testCase "000064-002.sig" (testSerialization "000064-002.sig"), | ||
97 | --testCase "000065-012.ring_trust" (testSerialization "000065-012.ring_trust"), | ||
98 | testCase "000066-013.user_id" (testSerialization "000066-013.user_id"), | ||
99 | --testCase "000067-002.sig" (testSerialization "000067-002.sig"), | ||
100 | --testCase "000068-012.ring_trust" (testSerialization "000068-012.ring_trust"), | ||
101 | testCase "000069-005.secret_key" (testSerialization "000069-005.secret_key"), | ||
102 | --testCase "000070-013.user_id" (testSerialization "000070-013.user_id"), | ||
103 | --testCase "000071-002.sig" (testSerialization "000071-002.sig"), | ||
104 | --testCase "000072-012.ring_trust" (testSerialization "000072-012.ring_trust"), | ||
105 | --testCase "000073-017.attribute" (testSerialization "000073-017.attribute"), | ||
106 | --testCase "000074-002.sig" (testSerialization "000074-002.sig"), | ||
107 | --testCase "000075-012.ring_trust" (testSerialization "000075-012.ring_trust"), | ||
108 | --testCase "000076-007.secret_subkey" (testSerialization "000076-007.secret_subkey"), | ||
109 | --testCase "000077-002.sig" (testSerialization "000077-002.sig"), | ||
110 | --testCase "000078-012.ring_trust" (testSerialization "000078-012.ring_trust"), | ||
111 | --testCase "pubring.gpg" (testSerialization "pubring.gpg"), | ||
112 | --testCase "secring.gpg" (testSerialization "secring.gpg"), | ||
113 | -- Issue #11 -- testCase "compressedsig.gpg" (testSerialization "compressedsig.gpg"), | ||
114 | -- Issue #11 -- testCase "compressedsig-zlib.gpg" (testSerialization "compressedsig-zlib.gpg"), | ||
115 | -- Issue #11 -- testCase "compressedsig-bzip2.gpg" (testSerialization "compressedsig-bzip2.gpg"), | ||
116 | testCase "onepass_sig" (testSerialization "onepass_sig") | ||
117 | -- Issue #11 -- testCase "uncompressed-ops-dsa.gpg" (testSerialization "uncompressed-ops-dsa.gpg"), | ||
118 | -- Issue #11 -- testCase "uncompressed-ops-rsa.gpg" (testSerialization "uncompressed-ops-rsa.gpg"), | ||
119 | ], | ||
120 | testGroup "S2K count" [ | ||
121 | testProperty "S2K count encode reverses decode" prop_s2k_count | ||
122 | ] | ||
123 | ] | ||
124 | |||
125 | main :: IO () | ||
126 | main = defaultMain tests | ||