]> code.delx.au - offlineimap/blobdiff - testsrc/TestInfrastructure.hs
Added first respText test
[offlineimap] / testsrc / TestInfrastructure.hs
index 0cd54100010dc7923f8612a9e3cf03309596f270..feb058e186473f2cf4fb34d7a594f48994b9abe6 100644 (file)
@@ -26,6 +26,7 @@ import Text.Printf
 import System.Random
 import Data.Word
 import Test.HUnit.Utils
+import Text.ParserCombinators.Parsec
 
 (@=?) :: (Eq a, Show a) => a -> a -> Result
 expected @=? actual = 
@@ -88,3 +89,12 @@ q = qccheck (defaultConfig {configMaxTest = 250, configMaxFail = 10000,
           testCount n _ = testCountBase n ++ 
                           replicate (length (testCountBase n)) '\b'
 
+{- | Test a parser, forcing it to apply to all input. -}
+p parser input = 
+    case parse parseTest "(none)" input of
+      Left _ -> Nothing
+      Right y -> Just y
+    where parseTest = do r <- parser
+                         eof
+                         return r
+