]> code.delx.au - offlineimap/commitdiff
Added text and test for it
authorJohn Goerzen <jgoerzen@complete.org>
Tue, 12 Aug 2008 06:03:49 +0000 (01:03 -0500)
committerJohn Goerzen <jgoerzen@complete.org>
Tue, 12 Aug 2008 06:04:26 +0000 (01:04 -0500)
All tests pass

src/Network/IMAP/Parser/Prim.hs
testsrc/TestParserPrim.hs

index 1f494511aa922ded2c1c51f87e4138eeb8b08a2a..204b0af8d0923880492f7e1b7ddd664881c2daed 100644 (file)
@@ -116,4 +116,8 @@ quotedChar =
     noneOf quotedSpecials <|> (do char '\\'
                                   oneOf quotedSpecials
                               )
-           
\ No newline at end of file
+
+-- | Fixme: should exclude 8-bit data per RFC3501           
+textChar = noneOf crlf
+
+text = many1 textChar
index 2438c6b150b743075d5cae98b9bec2b721c25146..36d44600c4f09a3ef9c0171cf3359df009af0232 100644 (file)
@@ -88,10 +88,19 @@ prop_astring s useQuoted =
        then p astring s @=? Just s
        else p astring (gen_string3501 s useQuoted) @=? Just s
 
+prop_text :: String -> Result
+prop_text s =
+    p text s @=? if isValid
+                 then Just s
+                 else Nothing
+    where isValid = not (null s) && all (`notElem` crlf) s
+
 allt = [q "quoted" prop_quoted,
         q "literal" prop_literal,
         q "string3501" prop_string3501,
         q "atom" prop_atom,
         q "astring basic" prop_astring_basic,
-        q "prop_astring" prop_astring
+        q "astring full" prop_astring,
+        q "text" prop_text
        ]
+