summaryrefslogtreecommitdiff
path: root/test-src/DataencQC.hs
diff options
context:
space:
mode:
Diffstat (limited to 'test-src/DataencQC.hs')
-rw-r--r--test-src/DataencQC.hs137
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
8module DataencQC
9 where
10
11import Test.Framework.TH
12
13import Data.Maybe
14import Data.Word
15import Test.QuickCheck
16import Test.Framework.Providers.QuickCheck2
17
18import qualified Codec.Binary.Uu as Uu
19import qualified Codec.Binary.Uu as Xx
20import qualified Codec.Binary.Base85 as Base85
21import qualified Codec.Binary.Base64 as Base64
22import qualified Codec.Binary.Base64Url as Base64Url
23import qualified Codec.Binary.Base32 as Base32
24import qualified Codec.Binary.Base32Hex as Base32Hex
25import qualified Codec.Binary.Base16 as Base16
26import qualified Codec.Binary.Yenc as Yenc
27import qualified Codec.Binary.QuotedPrintable as QP
28import qualified Codec.Binary.PythonString as Py
29import qualified Codec.Binary.Url as Url
30
31-- {{{1 uuencode properties
32prop_uuEncode ws = ws == (fromJust . Uu.decode . Uu.encode) ws
33 where types = ws::[Word8]
34
35prop_uuChop n ws = s == (Uu.unchop . Uu.chop n) s
36 where
37 types = (n :: Int, ws::[Word8])
38 s = Uu.encode ws
39
40prop_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
44prop_xxEncode ws = ws == (fromJust . Xx.decode . Xx.encode) ws
45 where types = ws::[Word8]
46
47prop_xxChop n ws = s == (Xx.unchop . Xx.chop n) s
48 where
49 types = (n:: Int, ws::[Word8])
50 s = Xx.encode ws
51
52prop_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
56prop_base85Encode ws = ws == fromJust (Base85.decode $ Base85.encode ws)
57 where types = ws::[Word8]
58
59prop_base85Chop n s = s == Base85.unchop (Base85.chop n s)
60 where types = (n::Int, s::String)
61
62-- {{{1 base64 properties
63prop_base64Encode ws = ws == fromJust (Base64.decode $ Base64.encode ws)
64 where types = ws::[Word8]
65
66prop_base64Chop n s = s == Base64.unchop (Base64.chop n s)
67 where types = (n::Int, s::String)
68
69-- {{{1 base64url properties
70prop_base64UrlEncode ws = ws == fromJust (Base64Url.decode $ Base64Url.encode ws)
71 where types = ws::[Word8]
72
73prop_base64UrlChop n s = s == Base64Url.unchop (Base64Url.chop n s)
74 where types = (n::Int, s::String)
75
76-- {{{1 base32
77prop_base32Encode ws = ws == fromJust (Base32.decode $ Base32.encode ws)
78 where types = ws::[Word8]
79
80prop_base32Chop n s = s == Base32.unchop (Base32.chop n s)
81 where types = (n::Int, s::String)
82
83-- {{{1 base32hex
84prop_base32HexEncode ws = ws == fromJust (Base32Hex.decode $ Base32Hex.encode ws)
85 where types = ws::[Word8]
86
87prop_base32HexChop n s = s == Base32Hex.unchop (Base32Hex.chop n s)
88 where types = (n::Int, s::String)
89
90-- {{{1 base16
91prop_base16Encode ws = ws == fromJust (Base16.decode $ Base16.encode ws)
92 where types = ws::[Word8]
93
94prop_base16Chop n s = s == Base16.unchop (Base16.chop n s)
95 where types = (n::Int, s::String)
96
97-- {{{1 yEncoding
98prop_yencEncode ws = ws == fromJust (Yenc.decode $ Yenc.encode ws)
99 where types = ws ::[Word8]
100
101prop_yencChop n ws = ws == Yenc.unchop (Yenc.chop n ws)
102 where types = (n::Int, ws :: [Word8])
103
104-- {{{1 qp
105prop_qpEncode ws = ws == fromJust (QP.decode $ QP.encode ws)
106 where types = ws :: [Word8]
107
108prop_qpChop n ws = s == (QP.unchop . QP.chop n) s
109 where
110 types = (n::Int, ws::[Word8])
111 s = QP.encode ws
112
113prop_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
117prop_pyEncode ws = ws == fromJust (Py.decode $ Py.encode ws)
118 where types = ws :: [Word8]
119
120prop_pyChop n s = s == Py.unchop (Py.chop n s)
121 where types = (n :: Int, s :: String)
122
123prop_pyCombined n ws = ws == fromJust (runAll ws)
124 where runAll = Py.decode . Py.unchop . Py.chop n . Py.encode
125
126-- {{{1 url
127prop_urlEncode ws = ws == fromJust (Url.decode $ Url.encode ws)
128 where types = ws :: [Word8]
129
130prop_urlChop n s = s == Url.unchop (Url.chop n s)
131 where types = (n :: Int, s :: String)
132
133prop_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
137allTests = $(testGroupGenerator)