From: John Goerzen Date: Tue, 12 Aug 2008 06:03:49 +0000 (-0500) Subject: Added text and test for it X-Git-Url: https://code.delx.au/offlineimap/commitdiff_plain/2cbc7b5013de5fb1d9266b00816375228dcd9470?hp=e46fc916b464e833c7e2e522f5631cfe4bcfc336 Added text and test for it All tests pass --- diff --git a/src/Network/IMAP/Parser/Prim.hs b/src/Network/IMAP/Parser/Prim.hs index 1f49451..204b0af 100644 --- a/src/Network/IMAP/Parser/Prim.hs +++ b/src/Network/IMAP/Parser/Prim.hs @@ -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 diff --git a/testsrc/TestParserPrim.hs b/testsrc/TestParserPrim.hs index 2438c6b..36d4460 100644 --- a/testsrc/TestParserPrim.hs +++ b/testsrc/TestParserPrim.hs @@ -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 ] +