]> code.delx.au - offlineimap/commitdiff
Added prop_readBytes
authorJohn Goerzen <jgoerzen@complete.org>
Tue, 12 Aug 2008 02:46:10 +0000 (21:46 -0500)
committerJohn Goerzen <jgoerzen@complete.org>
Tue, 12 Aug 2008 02:46:10 +0000 (21:46 -0500)
testsrc/TestConnection.hs

index 0bc6ac39a12bd52a072b0f54516e9a5229828f42..a8444113bed51c8129cc5162c5a22aaf4e4c97fc 100644 (file)
@@ -51,11 +51,18 @@ prop_readLine s =
         runLinesConnection s readLine @?=
             (head s, (expectedString (tail s), []))
 
+prop_readBytes :: String -> Int -> Property
+prop_readBytes s l =
+    l <= length s && l >= 0 ==> 
+      runStringConnection s (\c -> readBytes c (fromIntegral l)) ==
+                         (take l s, (drop l s, []))
+
 q :: Testable a => String -> a -> HU.Test
 q = qccheck (defaultConfig {configMaxTest = 250, configMaxFail = 5000})
 
 allt = [q "Identity" prop_identity,
         q "Lines identity" prop_linesidentity,
         q "Lines list identity" prop_lineslistidentity,
-        q "readline" prop_readLine
+        q "readline" prop_readLine,
+        q "readBytes" prop_readBytes
        ]