git.iko.soy/typeable/attoparsec
on master help sign in
Update ByteString.hs
commit6b141db3ecb669be0ab1502f5568be31fba8e7b9 authorSeanRBurton <burton.seanr@gmail.com> dateFri 28 Nov 2014, 07:00 (12 years ago) parent312dc9f
1 file changed+9
tests/QC/ByteString.hs+9
tests/QC/ByteString.hs+9
@@ -12,6 +12,7 @@ import Test.Framework.Providers.QuickCheck2 (testProperty)
1212import Test.QuickCheck
1313import qualified Data.Attoparsec.ByteString as P
1414import qualified Data.Attoparsec.ByteString.Char8 as P8
15+import qualified Data.Attoparsec.ByteString.FastSet as S
1516import qualified Data.Attoparsec.ByteString.Lazy as PL
1617import qualified Data.ByteString as B
1718import qualified Data.ByteString.Lazy as L
@@ -130,6 +131,14 @@ scan :: L.ByteString -> Positive Int64 -> Property
130131scan s (Positive k) = parseBS p s === Just (toStrictBS $ L.take k s)
131132 where p = P.scan k $ \ n _ ->
132133 if n > 0 then let !n' = n - 1 in Just n' else Nothing
134+
135+members :: [Word8] -> Property
136+ members s = property . all (`S.memberWord8` set) s
137+ where set = S.fromList s
138+
139+nonmembers :: [Word8] -> [Word8] -> Property
140+ nonmembers s s' = property . not . any (`S.memberWord8` set) $ filter (not . (`elem` s)) s'
141+ where set = S.fromList s
133142
134143tests :: [Test]
135144tests = [