Commit 45d2fd88 authored by Xia Li-yao's avatar Xia Li-yao Committed by Bodigrim
Browse files

Tests: Generate chunks that start in the middle of their buffers

parent 66e2bd09
...@@ -35,7 +35,7 @@ import Data.Char (isSpace) ...@@ -35,7 +35,7 @@ import Data.Char (isSpace)
import Data.Text.Foreign (I8) import Data.Text.Foreign (I8)
import Data.Text.Lazy.Builder.RealFloat (FPFormat(..)) import Data.Text.Lazy.Builder.RealFloat (FPFormat(..))
import Data.Word (Word8, Word16) import Data.Word (Word8, Word16)
import Test.QuickCheck (Arbitrary(..), arbitraryUnicodeChar, arbitraryBoundedEnum, getUnicodeString, arbitrarySizedIntegral, shrinkIntegral, Property, ioProperty, discard, counterexample, (===), (.&&.), NonEmptyList(..)) import Test.QuickCheck (Arbitrary(..), arbitraryUnicodeChar, arbitraryBoundedEnum, getUnicodeString, arbitrarySizedIntegral, shrinkIntegral, Property, ioProperty, discard, counterexample, scale, (===), (.&&.), NonEmptyList(..))
import Test.QuickCheck.Gen (Gen, choose, chooseAny, elements, frequency, listOf, oneof, resize, sized) import Test.QuickCheck.Gen (Gen, choose, chooseAny, elements, frequency, listOf, oneof, resize, sized)
import Tests.Utils import Tests.Utils
import qualified Data.ByteString as B import qualified Data.ByteString as B
...@@ -86,7 +86,10 @@ instance Arbitrary a => Arbitrary (Sqrt a) where ...@@ -86,7 +86,10 @@ instance Arbitrary a => Arbitrary (Sqrt a) where
shrink = map Sqrt . shrink . unSqrt shrink = map Sqrt . shrink . unSqrt
instance Arbitrary T.Text where instance Arbitrary T.Text where
arbitrary = (T.pack . getUnicodeString) `fmap` arbitrary arbitrary = do
t <- (T.pack . getUnicodeString) `fmap` scale (* 2) arbitrary
-- Generate chunks that start in the middle of their buffers.
(\i -> T.drop i t) <$> choose (0, T.length t)
shrink = map T.pack . shrink . T.unpack shrink = map T.pack . shrink . T.unpack
instance Arbitrary TL.Text where instance Arbitrary TL.Text where
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment