]> code.delx.au - offlineimap/blobdiff - testsrc/runtests.hs
Added quoted test
[offlineimap] / testsrc / runtests.hs
index 99d9a1c820414d5c05eda8bb25ff5da2e3958a0c..c0f27bb0951b2155b554040b3e27d4fda09f86b3 100644 (file)
@@ -21,52 +21,32 @@ import Test.QuickCheck
 import Test.QuickCheck.Batch
 import qualified Test.HUnit as HU
 import Test.HUnit.Utils
-import qualified Data.Map as Map
-import System.IO
-import Text.Printf
+import Data.List
+import System.IO(stderr)
+import Data.Word
 
-import Data.Syncable
+import TestInfrastructure
 
-prop_empty =
-    syncThem emptymap emptymap emptymap == ([], [], []) -- ([DeleteItem 5], [], [])
+import qualified TestSyncable
+import qualified TestConnection
+import qualified TestParser
+import qualified TestParserPrim
 
-keysToMap :: Ord k => [k] -> Map.Map k ()
-keysToMap = foldl (\map k -> Map.insert k () map) Map.empty
+q :: Testable a => String -> a -> HU.Test
+q = qccheck (defaultConfig {configMaxTest = 250})
 
-emptymap :: Map.Map Integer ()
-emptymap = Map.empty
+tl msg t = HU.TestLabel msg $ HU.TestList t
 
-allt = [("Empty", prop_empty)]
-alltHU = map (\(str, prop) -> qctest str prop) allt
+allt = [tl "TestSyncable" TestSyncable.allt,
+        tl "TestConnection" TestConnection.allt,
+        tl "TestParserPrim" TestParserPrim.allt,
+        tl "TestParser" TestParser.allt
+       ]
 
-testh = HU.runTestTT $ HU.TestList alltHU
-testv = runVerbTestText (HU.putTextToHandle stderr True) $ HU.TestList alltHU
+testh = HU.runTestTT $ HU.TestList allt
+testv = runVerbTestText (HU.putTextToHandle stderr True) $ HU.TestList allt
 
-testq = runTests "Test Stuff" defOpt (map (run . snd) allt)
-
-instance (Arbitrary k, Eq k, Ord k) => Arbitrary (Map.Map k ()) where
-    arbitrary = 
-        do items <- arbitrary
-           return $ keysToMap items
-    coarbitrary = coarbitrary . Map.keys
-
--- Modified from HUnit
-runVerbTestText :: HU.PutText st -> HU.Test -> IO (HU.Counts, st)
-runVerbTestText (HU.PutText put us) t = do
-  (counts, us') <- HU.performTest reportStart reportError reportFailure us t
-  us'' <- put (HU.showCounts counts) True us'
-  return (counts, us'')
- where
-  reportStart ss us = do hPrintf stderr "\rTesting %-68s\n" (HU.showPath (HU.path ss))
-                         put (HU.showCounts (HU.counts ss)) False us
-  reportError   = reportProblem "Error:"   "Error in:   "
-  reportFailure = reportProblem "Failure:" "Failure in: "
-  reportProblem p0 p1 msg ss us = put line True us
-   where line  = "### " ++ kind ++ path' ++ '\n' : msg
-         kind  = if null path' then p0 else p1
-         path' = HU.showPath (HU.path ss)
-
-         
+        
 main = 
     do testv
        return ()