Revision 468b828e htools/Ganeti/HTools/QC.hs
b/htools/Ganeti/HTools/QC.hs | ||
---|---|---|
449 | 449 |
|
450 | 450 |
-- ** Utils tests |
451 | 451 |
|
452 |
-- | Helper to generate a small string that doesn't contain commas. |
|
453 |
genNonCommaString = do |
|
454 |
size <- choose (0, 20) -- arbitrary max size |
|
455 |
vectorOf size (arbitrary `suchThat` ((/=) ',')) |
|
456 |
|
|
452 | 457 |
-- | If the list is not just an empty element, and if the elements do |
453 | 458 |
-- not contain commas, then join+split should be idempotent. |
454 | 459 |
prop_Utils_commaJoinSplit = |
455 |
forAll (arbitrary `suchThat`
|
|
456 |
(\l -> l /= [""] && all (notElem ',') l )) $ \lst ->
|
|
460 |
forAll (choose (0, 20)) $ \llen ->
|
|
461 |
forAll (vectorOf llen genNonCommaString `suchThat` ((/=) [""])) $ \lst ->
|
|
457 | 462 |
Utils.sepSplit ',' (Utils.commaJoin lst) ==? lst |
458 | 463 |
|
459 | 464 |
-- | Split and join should always be idempotent. |
Also available in: Unified diff