@@ -3,7 +3,8 @@
4module QC.Buffer (tests) where
4module QC.Buffer (tests) where
6+import Control.Applicative ((<$>))
6−import Data.Monoid (mconcat)
7+import Data.Monoid (Monoid(mconcat))
7import QC.Common ()
8import QC.Common ()
8import Test.Framework (Test)
9import Test.Framework (Test)
9import Test.Framework.Providers.QuickCheck2 (testProperty)
10import Test.Framework.Providers.QuickCheck2 (testProperty)
@@ -24,12 +25,19 @@ type BPT = BP T.Text BT.Buffer
24instance Arbitrary BPB where
25instance Arbitrary BPB where
25 arbitrary = do
26 arbitrary = do
26 bss <- arbitrary
27 bss <- arbitrary
28+ return $! toBP BB.buffer bss
27− return $! BP bss (mconcat bss) (mconcat (map BB.buffer bss))
30+ shrink (BP bss _ _) = toBP BB.buffer <$> shrink bss
29instance Arbitrary BPT where
32instance Arbitrary BPT where
30 arbitrary = do
33 arbitrary = do
31 bss <- arbitrary
34 bss <- arbitrary
35+ return $! toBP BT.buffer bss
37+ shrink (BP bss _ _) = toBP BT.buffer <$> shrink bss
39+toBP :: (Monoid a, Monoid b) => (a -> b) -> [a] -> BP a b
32− return $! BP bss (mconcat bss) (mconcat (map BT.buffer bss))
40+toBP buf bss = BP bss (mconcat bss) (mconcat (map buf bss))
34b_unbuffer :: BPB -> Property
42b_unbuffer :: BPB -> Property
35b_unbuffer (BP _ts t buf) = t === BB.unbuffer buf
43b_unbuffer (BP _ts t buf) = t === BB.unbuffer buf