import Data.List
import Data.Maybe(catMaybes)
import System.IO(stderr)
+import Data.Word
import Data.Syncable
import TestInfrastructure
in (expectedResMaster, []) @=?
(sort resMaster, resChild)
-prop_addFromMaster :: SyncCollection Int Float -> Result
+prop_addFromMaster :: SyncCollection Int Word8 -> Result
prop_addFromMaster inp =
let (resMaster, resChild) = syncBiDir inp emptymap emptymap
expectedResChild = sort . map (\(k, v) -> CopyItem k v) . Map.toList $ inp
-- FIXME: prop_addFromChild
-prop_allChangesToChild :: SyncCollection Int Float -> SyncCollection Int Float -> Result
+prop_allChangesToChild :: SyncCollection Int Word8 -> SyncCollection Int Word8 -> Result
prop_allChangesToChild master child =
let (resMaster, resChild) = syncBiDir master child child
expectedResChild = sort $
Just x -> if x /= v
then (k, x) : accum
else accum
- masterChanges = map (pairToFunc ModifyContent) . catMaybes .
- map checkIt . Map.toList . Map.intersection child
- $ master
- where checkIt (k, v) =
- case Map.lookup k master of
- Nothing -> Nothing
- Just v' -> if v /= v'
- then Just (k, v)
- else Nothing
- in (sort masterChanges, expectedResChild) @=?
+ in ([], expectedResChild) @=?
(sort resMaster, sort resChild)
-prop_allChangesToMaster :: SyncCollection Int Float -> SyncCollection Int Float -> Result
+prop_allChangesToMaster :: SyncCollection Int Word8 -> SyncCollection Int Word8 -> Result
prop_allChangesToMaster master child =
let (resMaster, resChild) = syncBiDir master child master
expectedResMaster = sort $
-- FIXME: test findModified
-prop_allChanges :: SyncCollection Int Float -> SyncCollection Int Float -> SyncCollection Int Float -> Result
+prop_allChanges :: SyncCollection Int Word8 -> SyncCollection Int Word8 -> SyncCollection Int Word8 -> Result
prop_allChanges master child lastchild =
let (resMaster, resChild) = syncBiDir master child lastchild
(sort resMaster, sort resChild)
{- | Basic validation that unaryApplyChanges works -}
-prop_unaryApplyChanges :: SyncCollection Int Float -> [(Bool, Int, Float)] -> Result
+prop_unaryApplyChanges :: SyncCollection Int Word8 -> [(Bool, Int, Word8)] -> Result
prop_unaryApplyChanges collection randcommands =
let -- We use nubBy to make sure we don't get input that has reference
-- to the same key more than once. We then convert True/False to
{- | Should validate both that unaryApplyChanges works, and that it is
an identify -}
-prop_unaryApplyChangesId :: SyncCollection Int Float -> SyncCollection Int Float -> Result
+prop_unaryApplyChangesId :: SyncCollection Int Word8 -> SyncCollection Int Word8 -> Result
prop_unaryApplyChangesId master child =
let (resMaster, resChild) = syncBiDir master child child
newMaster = unaryApplyChanges master resMaster
in (True, sort (Map.keys master), sort (Map.keys master)) @=?
(newMasterKeys == newChildKeys, newMasterKeys, newChildKeys)
-prop_unaryApplyChanges3 :: SyncCollection Int Float -> SyncCollection Int Float -> SyncCollection Int Float -> Result
+prop_unaryApplyChanges3 :: SyncCollection Int Word8 -> SyncCollection Int Word8 -> SyncCollection Int Word8 -> Result
prop_unaryApplyChanges3 master child lastChild =
let (resMaster, resChild) = syncBiDir master child lastChild
newMaster = unaryApplyChanges master resMaster
newChild = unaryApplyChanges child resChild
in newMaster @=? newChild
-prop_diffCollection :: SyncCollection Int Float -> SyncCollection Int Float -> Result
+prop_diffCollection :: SyncCollection Int Word8 -> SyncCollection Int Word8 -> Result
prop_diffCollection coll1 coll2 =
let commands = diffCollection coll1 coll2
newcoll2 = unaryApplyChanges coll1 commands
in coll2 @=? newcoll2
q :: Testable a => String -> a -> HU.Test
-q = qccheck defaultConfig
+q = qccheck (defaultConfig {configMaxTest = 250})
allt = [q "Empty" prop_empty,
q "Del all from child" prop_delAllFromChild,