import Test.QuickCheck
-import Cube
-import Grid (Grid)
-import Tests.Grid ()
+import Cube (Cube(Cube))
+import FunctionValues (FunctionValues(FunctionValues))
+import Tests.FunctionValues
instance Arbitrary Cube where
arbitrary = do
- g' <- arbitrary :: Gen Grid
+ (Positive h') <- arbitrary :: Gen (Positive Double)
i' <- choose (coordmin, coordmax)
j' <- choose (coordmin, coordmax)
k' <- choose (coordmin, coordmax)
- d' <- arbitrary :: Gen Double
- return (Cube g' i' j' k' d')
+ fv' <- arbitrary :: Gen FunctionValues
+ return (Cube h' i' j' k' fv')
where
coordmin = -268435456 -- -(2^29 / 2)
coordmax = 268435456 -- +(2^29 / 2)
+
+
+-- Quickcheck tests.
+
+-- | Since the grid size is necessarily positive, all tetrahedrons
+-- (which comprise cubes of positive volume) must have positive volume
+-- as well.
+-- prop_all_volumes_positive :: Cube -> Property
+-- prop_all_volumes_positive c =
+-- (delta > 0) ==> (null nonpositive_volumes)
+-- where
+-- delta = h (grid c)
+-- ts = tetrahedrons c
+-- volumes = map volume ts
+-- nonpositive_volumes = filter (<= 0) volumes