git.iko.soy/typeable/attoparsec
on master help sign in
Add test for FastSet
e130c39Ben Gamari
attoparsec.cabal+1
@@ -89,6 +89,7 @@ test-suite tests
89 QC.Rechunked
89 QC.Rechunked
90 QC.Simple
90 QC.Simple
91 QC.Text
91 QC.Text
92+ QC.Text.FastSet
92
93
93 ghc-options:
94 ghc-options:
94 -Wall -threaded -rtsopts
95 -Wall -threaded -rtsopts
tests/QC/Text.hs+3−1
@@ -8,7 +8,8 @@ import Control.Applicative ((<*>), (<$>))
8import Data.Int (Int64)
8import Data.Int (Int64)
9import Prelude hiding (take, takeWhile)
9import Prelude hiding (take, takeWhile)
10import QC.Common (liftOp, parseT)
10import QC.Common (liftOp, parseT)
11+import qualified QC.Text.FastSet as FastSet
11−import Test.Framework (Test)
12+import Test.Framework (Test, testGroup)
12import Test.Framework.Providers.QuickCheck2 (testProperty)
13import Test.Framework.Providers.QuickCheck2 (testProperty)
13import Test.QuickCheck
14import Test.QuickCheck
14import qualified Data.Attoparsec.Text as P
15import qualified Data.Attoparsec.Text as P
@@ -188,4 +189,5 @@ tests = [
188 , testProperty "takeWhile1_empty" takeWhile1_empty
189 , testProperty "takeWhile1_empty" takeWhile1_empty
189 , testProperty "members" members
190 , testProperty "members" members
190 , testProperty "nonmembers" nonmembers
191 , testProperty "nonmembers" nonmembers
192+ , testGroup "FastSet" FastSet.tests
191 ]
193 ]
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 ]