cidr_from_string,
cidr_tests,
combine_all,
- prop_all_cidrs_contain_themselves
+ contains,
+ contains_proper,
+ prop_all_cidrs_contain_themselves,
+ prop_contains_proper_intransitive
) where
import Data.List (nubBy)
contains_proper :: Cidr -> Cidr -> Bool
contains_proper cidr1 cidr2 =
- (cidr1 `contains` cidr2) && (not (cidr1 == cidr2))
+ (cidr1 `contains` cidr2) && (not (cidr2 `contains` cidr1))
-- A CIDR range is redundant (with respect to the given list) if
prop_all_cidrs_contain_themselves :: Cidr -> Bool
prop_all_cidrs_contain_themselves cidr1 = cidr1 `contains` cidr1
+
+-- If cidr1 properly contains cidr2, then by definition cidr2
+-- does not properly contain cidr1.
+prop_contains_proper_intransitive :: Cidr -> Cidr -> Property
+prop_contains_proper_intransitive cidr1 cidr2 =
+ (cidr1 `contains_proper` cidr2) ==>
+ (not (cidr2 `contains_proper` cidr1))
import Test.QuickCheck.Batch
import Cidr (cidr_tests,
- prop_all_cidrs_contain_themselves)
+ prop_all_cidrs_contain_themselves,
+ prop_contains_proper_intransitive)
import IPv4Address (ipv4address_tests)
import Maskable (maskable_tests)
putStrLn "QuickCheck"
putStrLn "----------"
- runTests "Cidr" options [ run prop_all_cidrs_contain_themselves ]
+ runTests "Cidr" options [ run prop_all_cidrs_contain_themselves,
+ run prop_contains_proper_intransitive]