module Test.Ganeti.HTools.PeerMap (testHTools_PeerMap) where
import Test.QuickCheck
import Test.Ganeti.TestHelper
import Test.Ganeti.TestCommon
import qualified Ganeti.HTools.PeerMap as PeerMap
prop_addIdempotent :: PeerMap.PeerMap
-> PeerMap.Key -> PeerMap.Elem -> Property
prop_addIdempotent pmap key em =
fn (fn puniq) ==? fn puniq
where fn = PeerMap.add key em
puniq = PeerMap.accumArray const pmap
prop_removeIdempotent :: PeerMap.PeerMap -> PeerMap.Key -> Property
prop_removeIdempotent pmap key =
fn (fn puniq) ==? fn puniq
where fn = PeerMap.remove key
puniq = PeerMap.accumArray const pmap
prop_findMissing :: PeerMap.PeerMap -> PeerMap.Key -> Property
prop_findMissing pmap key =
PeerMap.find key (PeerMap.remove key puniq) ==? 0
where puniq = PeerMap.accumArray const pmap
prop_addFind :: PeerMap.PeerMap
-> PeerMap.Key -> PeerMap.Elem -> Property
prop_addFind pmap key em =
PeerMap.find key (PeerMap.add key em puniq) ==? em
where puniq = PeerMap.accumArray const pmap
prop_maxElem :: PeerMap.PeerMap -> Property
prop_maxElem pmap =
PeerMap.maxElem puniq ==? if null puniq then 0
else (maximum . snd . unzip) puniq
where puniq = PeerMap.accumArray const pmap
testSuite "HTools/PeerMap"
[ 'prop_addIdempotent
, 'prop_removeIdempotent
, 'prop_maxElem
, 'prop_addFind
, 'prop_findMissing
]