summaryrefslogtreecommitdiff
path: root/tests/Main.hs
diff options
context:
space:
mode:
authorSam T <pxqr.sta@gmail.com>2013-06-07 23:27:31 +0400
committerSam T <pxqr.sta@gmail.com>2013-06-07 23:27:31 +0400
commita30bb766e8f2bea19e5a8f1739354d5f7894df1d (patch)
tree5209629a266b6cc007f1e3d24469b70a0a4c6960 /tests/Main.hs
parentec063c9e50aa6f19e82e836a33c10d596f766290 (diff)
~ Fix bitfield encoding.
Diffstat (limited to 'tests/Main.hs')
-rw-r--r--tests/Main.hs12
1 files changed, 10 insertions, 2 deletions
diff --git a/tests/Main.hs b/tests/Main.hs
index 0e18a06b..84870d66 100644
--- a/tests/Main.hs
+++ b/tests/Main.hs
@@ -185,6 +185,15 @@ instance Arbitrary Message where
185 , Cancel <$> arbitrary 185 , Cancel <$> arbitrary
186 , Port <$> arbitrary 186 , Port <$> arbitrary
187 ] 187 ]
188-- todo add all messages
189
190prop_messageEncoding :: Message -> Bool
191prop_messageEncoding msg @ (Bitfield bf)
192 = case S.decode (S.encode msg) of
193 Right (Bitfield bf') -> bf == adjustSize (totalCount bf) bf'
194 Left _ -> False
195prop_messageEncoding msg
196 = S.decode (S.encode msg) == Right msg
188 197
189{----------------------------------------------------------------------- 198{-----------------------------------------------------------------------
190 Main 199 Main
@@ -209,7 +218,6 @@ main = defaultMain $
209 -- handshake module 218 -- handshake module
210 , testProperty "handshake encoding" $ 219 , testProperty "handshake encoding" $
211 prop_cerealEncoding (T :: T Handshake) 220 prop_cerealEncoding (T :: T Handshake)
212 , testProperty "message encoding" $ 221 , testProperty "message encoding" prop_messageEncoding
213 prop_cerealEncoding (T :: T Message)
214 222
215 ] ++ test_scrape_url 223 ] ++ test_scrape_url