]> code.delx.au - offlineimap/commitdiff
Added new (passing) test to compute all changes
authorJohn Goerzen <jgoerzen@complete.org>
Wed, 28 May 2008 10:06:37 +0000 (05:06 -0500)
committerJohn Goerzen <jgoerzen@complete.org>
Wed, 28 May 2008 10:06:37 +0000 (05:06 -0500)
testsrc/runtests.hs

index 87206648eb92a6d028a36add287a7f9b8c1c76af..fae901c82594f927d77b0e7b5056a0c0488c6d9a 100644 (file)
@@ -71,12 +71,25 @@ prop_allChangesToMaster master child =
         in (expectedResMaster, []) @=?
            (sort resMaster, resChild)
 
+prop_allChanges :: SyncCollection Int -> SyncCollection Int -> SyncCollection Int -> Result
+prop_allChanges master child lastchild =
+    let (resMaster, resChild) = syncThem master child lastchild
+        expectedResMaster = sort $
+            (map CopyItem . Map.keys . Map.difference child $ Map.union master lastchild) ++
+                                                                                            (map DeleteItem . Map.keys . Map.intersection master $ Map.difference lastchild child)
+        expectedResChild = sort $
+            (map CopyItem . Map.keys . Map.difference master $ Map.union child lastchild) ++
+                                                                                            (map DeleteItem . Map.keys . Map.intersection child $ Map.difference lastchild master)
+    in (expectedResMaster, expectedResChild) @=?
+       (sort resMaster, sort resChild)
+
 allt = [qctest "Empty" prop_empty,
         qctest "Del all from child" prop_delAllFromChild,
         qctest "Del all from master" prop_delAllFromMaster,
         qctest "Add from master" prop_addFromMaster,
         qctest "All changes to child" prop_allChangesToChild,
-        qctest "All changes to master" prop_allChangesToMaster
+        qctest "All changes to master" prop_allChangesToMaster,
+        qctest "All changes" prop_allChanges
        ]
 
 testh = HU.runTestTT $ HU.TestList allt