From: John Goerzen Date: Tue, 12 Aug 2008 06:09:16 +0000 (-0500) Subject: Added tag and test for it. All tests pass. X-Git-Url: https://code.delx.au/offlineimap/commitdiff_plain/beabf8c812d4728f258ca5404dc7009cc0c571b2 Added tag and test for it. All tests pass. --- diff --git a/src/Network/IMAP/Parser/Prim.hs b/src/Network/IMAP/Parser/Prim.hs index 204b0af..13946f5 100644 --- a/src/Network/IMAP/Parser/Prim.hs +++ b/src/Network/IMAP/Parser/Prim.hs @@ -121,3 +121,7 @@ quotedChar = textChar = noneOf crlf text = many1 textChar + +tag = many1 tagChar + where tagChar = (char '+' >> fail "No + for tag") <|> + astringChar \ No newline at end of file diff --git a/testsrc/TestParserPrim.hs b/testsrc/TestParserPrim.hs index 36d4460..8737c93 100644 --- a/testsrc/TestParserPrim.hs +++ b/testsrc/TestParserPrim.hs @@ -95,12 +95,23 @@ prop_text s = else Nothing where isValid = not (null s) && all (`notElem` crlf) s +prop_tag :: String -> Result +prop_tag s = + p tag s @=? if isValid + then Just s + else Nothing + where isValid = not (null s) && all isValidChar s + isValidChar c = + c `notElem` ('+' : atomSpecials) || + c `elem` respSpecials + allt = [q "quoted" prop_quoted, q "literal" prop_literal, q "string3501" prop_string3501, q "atom" prop_atom, q "astring basic" prop_astring_basic, q "astring full" prop_astring, - q "text" prop_text + q "text" prop_text, + q "tag" prop_tag ]