Skip to content

Commit

Permalink
Add property tests for genNonEmptyDisjointSet.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanknowles committed May 7, 2024
1 parent ce5307f commit 247442a
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions lib/test-utils/test/Test/QuickCheck/ExtraSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,12 @@ import Test.QuickCheck
, scale
, shrinkIntegral
, within
, (=/=)
, (===)
)
import Test.QuickCheck.Extra
( Pretty (..)
, genNonEmptyDisjointSet
, genShrinkSequence
, genericRoundRobinShrink
, getDisjointPair
Expand Down Expand Up @@ -191,6 +193,17 @@ spec = describe "Test.QuickCheck.ExtraSpec" $ do
prop_selectMapEntries_union
@Int @Int & property

describe "Generating and shrinking sets" $ do

describe "Generation" $ do

it "prop_genNonEmptyDisjointSet_disjoint" $
prop_genNonEmptyDisjointSet_disjoint
@Int & property
it "prop_genNonEmptyDisjointSet_nonEmpty" $
prop_genNonEmptyDisjointSet_nonEmpty
@Int & property

describe "Generating and shrinking associative maps" $ do

describe "Shrinking" $ do
Expand Down Expand Up @@ -575,6 +588,34 @@ prop_partitionList_LT (PartitionListData (x, y) as) =
x' = max 0 x
y' = max 1 (max y x')

--------------------------------------------------------------------------------
-- Generating sets
--------------------------------------------------------------------------------

prop_genNonEmptyDisjointSet_disjoint
:: (Arbitrary a, Ord a, Show a)
=> Set a
-> Property
prop_genNonEmptyDisjointSet_disjoint set1 =
forAll (genNonEmptyDisjointSet arbitrary set1) $ \set2 ->
Set.intersection set1 set2 === Set.empty
& cover 10
(Set.size set1 >= 10 && Set.size set2 >= 10)
"Set.size set1 >= 10 && Set.size set2 >= 10"
& checkCoverage

prop_genNonEmptyDisjointSet_nonEmpty
:: (Arbitrary a, Ord a, Show a)
=> Set a
-> Property
prop_genNonEmptyDisjointSet_nonEmpty set1 =
forAll (genNonEmptyDisjointSet arbitrary set1) $ \set2 ->
Set.size set2 =/= 0
& cover 10
(Set.size set1 >= 10 && Set.size set2 >= 10)
"Set.size set1 >= 10 && Set.size set2 >= 10"
& checkCoverage

--------------------------------------------------------------------------------
-- Selecting map entries (one at a time)
--------------------------------------------------------------------------------
Expand Down

0 comments on commit 247442a

Please sign in to comment.