]> code.delx.au - offlineimap/commitdiff
New test for literal
authorJohn Goerzen <jgoerzen@complete.org>
Tue, 12 Aug 2008 05:39:32 +0000 (00:39 -0500)
committerJohn Goerzen <jgoerzen@complete.org>
Tue, 12 Aug 2008 05:39:32 +0000 (00:39 -0500)
testsrc/TestParserPrim.hs

index 86046b47d427da4cd6568ce3946ad8dc41473a5d..49c4a325085c018b36735684c7725c671163850d 100644 (file)
@@ -36,11 +36,22 @@ p parser input =
 
 prop_quoted :: String -> Result
 prop_quoted s =
-    p quoted quotedString @?= Right s
-    where quotedString = '"' : concatMap quoteChar s ++ "\""
-          quoteChar '\\' = "\\\\"
+    p quoted (gen_quoted s) @?= Right s
+
+gen_quoted :: String -> String
+gen_quoted s = '"' : concatMap quoteChar s ++ "\""
+    where quoteChar '\\' = "\\\\"
           quoteChar '"' = "\\\""
           quoteChar x = [x]
 
-allt = [q "quoted" prop_quoted
+prop_literal :: String -> Result
+prop_literal s =
+    p literal (gen_literal s) @?= Right s
+
+gen_literal :: String -> String
+gen_literal s =
+    "{" ++ show (length s) ++ "}\r\n" ++ s
+
+allt = [q "quoted" prop_quoted,
+        q "literal" prop_literal
        ]