diff options
Diffstat (limited to 'test-src/DataencQC.hs')
-rw-r--r-- | test-src/DataencQC.hs | 137 |
1 files changed, 137 insertions, 0 deletions
diff --git a/test-src/DataencQC.hs b/test-src/DataencQC.hs new file mode 100644 index 0000000..d35c09c --- /dev/null +++ b/test-src/DataencQC.hs | |||
@@ -0,0 +1,137 @@ | |||
1 | {-# OPTIONS_GHC -XTemplateHaskell #-} | ||
2 | |||
3 | {- | ||
4 | - Copyright : (c) 2007 Magnus Therning | ||
5 | - License : BSD3 | ||
6 | -} | ||
7 | |||
8 | module DataencQC | ||
9 | where | ||
10 | |||
11 | import Test.Framework.TH | ||
12 | |||
13 | import Data.Maybe | ||
14 | import Data.Word | ||
15 | import Test.QuickCheck | ||
16 | import Test.Framework.Providers.QuickCheck2 | ||
17 | |||
18 | import qualified Codec.Binary.Uu as Uu | ||
19 | import qualified Codec.Binary.Uu as Xx | ||
20 | import qualified Codec.Binary.Base85 as Base85 | ||
21 | import qualified Codec.Binary.Base64 as Base64 | ||
22 | import qualified Codec.Binary.Base64Url as Base64Url | ||
23 | import qualified Codec.Binary.Base32 as Base32 | ||
24 | import qualified Codec.Binary.Base32Hex as Base32Hex | ||
25 | import qualified Codec.Binary.Base16 as Base16 | ||
26 | import qualified Codec.Binary.Yenc as Yenc | ||
27 | import qualified Codec.Binary.QuotedPrintable as QP | ||
28 | import qualified Codec.Binary.PythonString as Py | ||
29 | import qualified Codec.Binary.Url as Url | ||
30 | |||
31 | -- {{{1 uuencode properties | ||
32 | prop_uuEncode ws = ws == (fromJust . Uu.decode . Uu.encode) ws | ||
33 | where types = ws::[Word8] | ||
34 | |||
35 | prop_uuChop n ws = s == (Uu.unchop . Uu.chop n) s | ||
36 | where | ||
37 | types = (n :: Int, ws::[Word8]) | ||
38 | s = Uu.encode ws | ||
39 | |||
40 | prop_uuCombined n ws = ws == fromJust (Uu.decode $ Uu.unchop $ Uu.chop n $ Uu.encode ws) | ||
41 | where types = (n::Int, ws::[Word8]) | ||
42 | |||
43 | -- {{{1 xxencode properties | ||
44 | prop_xxEncode ws = ws == (fromJust . Xx.decode . Xx.encode) ws | ||
45 | where types = ws::[Word8] | ||
46 | |||
47 | prop_xxChop n ws = s == (Xx.unchop . Xx.chop n) s | ||
48 | where | ||
49 | types = (n:: Int, ws::[Word8]) | ||
50 | s = Xx.encode ws | ||
51 | |||
52 | prop_xxCombined n ws = ws == fromJust (Xx.decode $ Xx.unchop $ Xx.chop n $ Xx.encode ws) | ||
53 | where types = (n::Int, ws::[Word8]) | ||
54 | |||
55 | -- {{{1 base85 properties | ||
56 | prop_base85Encode ws = ws == fromJust (Base85.decode $ Base85.encode ws) | ||
57 | where types = ws::[Word8] | ||
58 | |||
59 | prop_base85Chop n s = s == Base85.unchop (Base85.chop n s) | ||
60 | where types = (n::Int, s::String) | ||
61 | |||
62 | -- {{{1 base64 properties | ||
63 | prop_base64Encode ws = ws == fromJust (Base64.decode $ Base64.encode ws) | ||
64 | where types = ws::[Word8] | ||
65 | |||
66 | prop_base64Chop n s = s == Base64.unchop (Base64.chop n s) | ||
67 | where types = (n::Int, s::String) | ||
68 | |||
69 | -- {{{1 base64url properties | ||
70 | prop_base64UrlEncode ws = ws == fromJust (Base64Url.decode $ Base64Url.encode ws) | ||
71 | where types = ws::[Word8] | ||
72 | |||
73 | prop_base64UrlChop n s = s == Base64Url.unchop (Base64Url.chop n s) | ||
74 | where types = (n::Int, s::String) | ||
75 | |||
76 | -- {{{1 base32 | ||
77 | prop_base32Encode ws = ws == fromJust (Base32.decode $ Base32.encode ws) | ||
78 | where types = ws::[Word8] | ||
79 | |||
80 | prop_base32Chop n s = s == Base32.unchop (Base32.chop n s) | ||
81 | where types = (n::Int, s::String) | ||
82 | |||
83 | -- {{{1 base32hex | ||
84 | prop_base32HexEncode ws = ws == fromJust (Base32Hex.decode $ Base32Hex.encode ws) | ||
85 | where types = ws::[Word8] | ||
86 | |||
87 | prop_base32HexChop n s = s == Base32Hex.unchop (Base32Hex.chop n s) | ||
88 | where types = (n::Int, s::String) | ||
89 | |||
90 | -- {{{1 base16 | ||
91 | prop_base16Encode ws = ws == fromJust (Base16.decode $ Base16.encode ws) | ||
92 | where types = ws::[Word8] | ||
93 | |||
94 | prop_base16Chop n s = s == Base16.unchop (Base16.chop n s) | ||
95 | where types = (n::Int, s::String) | ||
96 | |||
97 | -- {{{1 yEncoding | ||
98 | prop_yencEncode ws = ws == fromJust (Yenc.decode $ Yenc.encode ws) | ||
99 | where types = ws ::[Word8] | ||
100 | |||
101 | prop_yencChop n ws = ws == Yenc.unchop (Yenc.chop n ws) | ||
102 | where types = (n::Int, ws :: [Word8]) | ||
103 | |||
104 | -- {{{1 qp | ||
105 | prop_qpEncode ws = ws == fromJust (QP.decode $ QP.encode ws) | ||
106 | where types = ws :: [Word8] | ||
107 | |||
108 | prop_qpChop n ws = s == (QP.unchop . QP.chop n) s | ||
109 | where | ||
110 | types = (n::Int, ws::[Word8]) | ||
111 | s = QP.encode ws | ||
112 | |||
113 | prop_qpCombined n ws = ws == fromJust (QP.decode $ QP.unchop $ QP.chop n $ QP.encode ws) | ||
114 | where types = (n::Int, ws::[Word8]) | ||
115 | |||
116 | -- {{{1 py | ||
117 | prop_pyEncode ws = ws == fromJust (Py.decode $ Py.encode ws) | ||
118 | where types = ws :: [Word8] | ||
119 | |||
120 | prop_pyChop n s = s == Py.unchop (Py.chop n s) | ||
121 | where types = (n :: Int, s :: String) | ||
122 | |||
123 | prop_pyCombined n ws = ws == fromJust (runAll ws) | ||
124 | where runAll = Py.decode . Py.unchop . Py.chop n . Py.encode | ||
125 | |||
126 | -- {{{1 url | ||
127 | prop_urlEncode ws = ws == fromJust (Url.decode $ Url.encode ws) | ||
128 | where types = ws :: [Word8] | ||
129 | |||
130 | prop_urlChop n s = s == Url.unchop (Url.chop n s) | ||
131 | where types = (n :: Int, s :: String) | ||
132 | |||
133 | prop_urlCombined n ws = ws == fromJust (runAll ws) | ||
134 | where runAll = Url.decode . Url.unchop . Url.chop n . Url.encode | ||
135 | |||
136 | -- {{{1 all the tests | ||
137 | allTests = $(testGroupGenerator) | ||