git.iko.soy/typeable/attoparsec
on master help sign in
Ensure that stringCI is actually tested (gh-99)
commit9db245f6ed37635fdc5f0c316fd7d28fab419842 authorBryan O'Sullivan <bos@serpentine.com> dateSun 5 Apr 2015, 11:45 (12 years ago) parent06d8436
1 file changed+10−2
tests/QC/ByteString.hs+10−2
tests/QC/ByteString.hs+10−2
@@ -5,11 +5,11 @@ module QC.ByteString (tests) where
55import Control.Applicative ((<*>))
66#endif
77import Control.Applicative ((<$>))
8−import Data.Char (chr, ord)
8+import Data.Char (chr, ord, toUpper)
99import Data.Int (Int64)
1010import Data.Word (Word8)
1111import Prelude hiding (take, takeWhile)
12−import QC.Common (liftOp, parseBS, toStrictBS)
12+import QC.Common (ASCII(..), liftOp, parseBS, toStrictBS)
1313import Test.Framework (Test)
1414import Test.Framework.Providers.QuickCheck2 (testProperty)
1515import Test.QuickCheck
@@ -18,6 +18,7 @@ import qualified Data.Attoparsec.ByteString.Char8 as P8
1818import qualified Data.Attoparsec.ByteString.FastSet as S
1919import qualified Data.Attoparsec.ByteString.Lazy as PL
2020import qualified Data.ByteString as B
21+import qualified Data.ByteString.Char8 as B8
2122import qualified Data.ByteString.Lazy as L
2223import qualified Data.ByteString.Lazy.Char8 as L8
2324
@@ -66,6 +67,12 @@ string :: L.ByteString -> L.ByteString -> Property
6667string s t = parseBS (P.string s') (s `L.append` t) === Just s'
6768 where s' = toStrictBS s
6869
70+stringCI :: ASCII L.ByteString -> ASCII L.ByteString -> Property
71+stringCI (ASCII s) (ASCII t) =
72+ parseBS (P8.stringCI up) (s `L.append` t) === Just s'
73+ where s' = toStrictBS s
74+ up = B8.map toUpper s'
75+
6976strings :: L.ByteString -> L.ByteString -> L.ByteString -> Property
7077strings s t u =
7178 parseBS (P.string (toStrictBS s) >> P.string t') (L.concat [s,t,u])
@@ -163,6 +170,7 @@ tests = [
163170 , testProperty "skip" skip
164171 , testProperty "skipWhile" skipWhile
165172 , testProperty "string" string
173+ , testProperty "stringCI" stringCI
166174 , testProperty "strings" strings
167175 , testProperty "take" take
168176 , testProperty "takeByteString" takeByteString