@@ -43,6 +43,13 @@ tests =
4343 , testGroup "getByteString"
4444 [ testProperty "prop_getByteString_negative" prop_getByteString_negative ]
4545
46+ , testGroup "getLazyByteString"
47+ [ testProperty "getLazyByteString == getByteString"
48+ prop_getLazyByteString_equal_to_ByteString
49+ , testProperty "getLazyByteString == getByteString (with shift)"
50+ prop_getLazyByteString_equal_to_ByteString2
51+ ]
52+
4653 , testGroup "Fail"
4754 [ testProperty "monadic fail" prop_fail ]
4855
@@ -110,6 +117,17 @@ tests =
110117 ]
111118 ]
112119
120+prop_getLazyByteString_equal_to_ByteString :: L.ByteString -> Int -> Property
121+prop_getLazyByteString_equal_to_ByteString bs n =
122+ (fromIntegral n) <= L.length bs ==>
123+ runGet (runBitGet (getLazyByteString (fromIntegral n))) bs ==
124+ (L.fromChunks . (:[]) $ runGet (runBitGet (getByteString n)) bs)
125+
126+prop_getLazyByteString_equal_to_ByteString2 :: L.ByteString -> Int -> Property
127+prop_getLazyByteString_equal_to_ByteString2 bs n =
128+ (L.length bs > 1) && (fromIntegral n) < L.length bs ==>
129+ runGet (runBitGet (getWord8 2 >> getLazyByteString (fromIntegral n))) bs ==
130+ (L.fromChunks . (:[]) $ runGet (runBitGet (getWord8 2 >> getByteString n)) bs)
113131
114132prop_getByteString_negative :: Int -> Property
115133prop_getByteString_negative n =