diff options
Diffstat (limited to 'tests/Main.hs')
-rw-r--r-- | tests/Main.hs | 12 |
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 | |||
190 | prop_messageEncoding :: Message -> Bool | ||
191 | prop_messageEncoding msg @ (Bitfield bf) | ||
192 | = case S.decode (S.encode msg) of | ||
193 | Right (Bitfield bf') -> bf == adjustSize (totalCount bf) bf' | ||
194 | Left _ -> False | ||
195 | prop_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 |