git.iko.soy/typeable/attoparsec
on master help sign in
Add test for FastSet
commite130c3935c18f5ad55db70a05ebdbcc001a11313 authorBen Gamari <ben@smart-cactus.org> dateFri 8 Apr 2016, 11:54 (11 years ago) parenta3d274e
3 files changed+19−1
attoparsec.cabal+1 tests/QC/Text.hs+3−1 tests/QC/Text/FastSet.hs+15
attoparsec.cabal+1
@@ -89,6 +89,7 @@ test-suite tests
8989 QC.Rechunked
9090 QC.Simple
9191 QC.Text
92+ QC.Text.FastSet
9293
9394 ghc-options:
9495 -Wall -threaded -rtsopts
tests/QC/Text.hs+3−1
@@ -8,7 +8,8 @@ import Control.Applicative ((<*>), (<$>))
88import Data.Int (Int64)
99import Prelude hiding (take, takeWhile)
1010import QC.Common (liftOp, parseT)
11−import Test.Framework (Test)
11+import qualified QC.Text.FastSet as FastSet
12+import Test.Framework (Test, testGroup)
1213import Test.Framework.Providers.QuickCheck2 (testProperty)
1314import Test.QuickCheck
1415import qualified Data.Attoparsec.Text as P
@@ -188,4 +189,5 @@ tests = [
188189 , testProperty "takeWhile1_empty" takeWhile1_empty
189190 , testProperty "members" members
190191 , testProperty "nonmembers" nonmembers
192+ , testGroup "FastSet" FastSet.tests
191193 ]
tests/QC/Text/FastSet.hsnew file+15
@@ -0,0 +1,15 @@
1+module QC.Text.FastSet where
2+
3+import Test.Framework (Test)
4+import Test.Framework.Providers.QuickCheck2 (testProperty)
5+import Test.QuickCheck
6+import qualified Data.Attoparsec.Text.FastSet as FastSet
7+
8+membershipCorrect :: String -> String -> Property
9+membershipCorrect members others =
10+ let fs = FastSet.fromList members
11+ correct c = (c `FastSet.member` fs) == (c `elem` members)
12+ in property $ all correct (members ++ others)
13+
14+tests :: [Test]
15+tests = [ testProperty "membership is correct" membershipCorrect ]