@@ -50,6 +50,13 @@ tests =
5050 prop_getLazyByteString_equal_to_ByteString2
5151 ]
5252
53+ , testGroup "isEmpty"
54+ [ testProperty "prop_isEmptyOfEmptyEmpty" prop_isEmptyOfEmptyEmpty
55+ , testProperty "prop_isEmptyOfNonEmptyEmpty" prop_isEmptyOfNonEmptyEmpty
56+ , testProperty "prop_isEmptyOfConsumedEmpty" prop_isEmptyOfConsumedEmpty
57+ , testProperty "prop_isEmptyOfNotConsumedNotEmpty" prop_isEmptyOfNotConsumedNotEmpty
58+ ]
59+
5360 , testGroup "Fail"
5461 [ testProperty "monadic fail" prop_fail ]
5562
@@ -117,6 +124,23 @@ tests =
117124 ]
118125 ]
119126
127+prop_isEmptyOfEmptyEmpty :: Bool
128+prop_isEmptyOfEmptyEmpty = runGet (runBitGet isEmpty) L.empty
129+
130+prop_isEmptyOfNonEmptyEmpty :: L.ByteString -> Property
131+prop_isEmptyOfNonEmptyEmpty bs =
132+ not (L.null bs) ==> runGet (runBitGet isEmpty) bs == False
133+
134+prop_isEmptyOfConsumedEmpty :: L.ByteString -> Int -> Property
135+prop_isEmptyOfConsumedEmpty bs n =
136+ (fromIntegral n) == L.length bs && not (L.null bs) ==>
137+ runGet (runBitGet (getByteString n >> isEmpty)) bs == True
138+
139+prop_isEmptyOfNotConsumedNotEmpty :: L.ByteString -> Int -> Property
140+prop_isEmptyOfNotConsumedNotEmpty bs n =
141+ (fromIntegral n) < L.length bs && not (L.null bs) ==>
142+ runGet (runBitGet (getByteString n >> isEmpty)) bs == False
143+
120144prop_getLazyByteString_equal_to_ByteString :: L.ByteString -> Int -> Property
121145prop_getLazyByteString_equal_to_ByteString bs n =
122146 (fromIntegral n) <= L.length bs ==>