module Tests.Cube where import Test.QuickCheck import Cube (Cube(Cube)) import FunctionValues (FunctionValues(FunctionValues)) import Tests.FunctionValues instance Arbitrary Cube where arbitrary = do (Positive h') <- arbitrary :: Gen (Positive Double) i' <- choose (coordmin, coordmax) j' <- choose (coordmin, coordmax) k' <- choose (coordmin, coordmax) 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