Revision 01606931 htools/Ganeti/HTools/QC.hs
b/htools/Ganeti/HTools/QC.hs | ||
---|---|---|
605 | 605 |
, Qlang.GTFilter <$> getName <*> value |
606 | 606 |
, Qlang.LEFilter <$> getName <*> value |
607 | 607 |
, Qlang.GEFilter <$> getName <*> value |
608 |
, Qlang.RegexpFilter <$> getName <*> getName
|
|
608 |
, Qlang.RegexpFilter <$> getName <*> arbitrary
|
|
609 | 609 |
, Qlang.ContainsFilter <$> getName <*> value |
610 | 610 |
] |
611 | 611 |
where value = oneof [ Qlang.QuotedString <$> getName |
... | ... | |
623 | 623 |
instance Arbitrary Qlang.ItemType where |
624 | 624 |
arbitrary = elements [minBound..maxBound] |
625 | 625 |
|
626 |
instance Arbitrary Qlang.FilterRegex where |
|
627 |
arbitrary = getName >>= Qlang.mkRegex -- a name should be a good regex |
|
628 |
|
|
626 | 629 |
-- * Actual tests |
627 | 630 |
|
628 | 631 |
-- ** Utils tests |
... | ... | |
2089 | 2092 |
forAll genFilter $ \flt -> |
2090 | 2093 |
J.readJSON (J.showJSON flt) ==? J.Ok flt |
2091 | 2094 |
|
2095 |
prop_Qlang_FilterRegex_instances :: Qlang.FilterRegex -> Property |
|
2096 |
prop_Qlang_FilterRegex_instances rex = |
|
2097 |
printTestCase "failed JSON encoding" |
|
2098 |
(J.readJSON (J.showJSON rex) ==? J.Ok rex) .&&. |
|
2099 |
printTestCase "failed read/show instances" (read (show rex) ==? rex) |
|
2100 |
|
|
2092 | 2101 |
testSuite "Qlang" |
2093 | 2102 |
[ 'prop_Qlang_Serialisation |
2103 |
, 'prop_Qlang_FilterRegex_instances |
|
2094 | 2104 |
] |
2095 | 2105 |
|
2096 | 2106 |
|
Also available in: Unified diff