]> gitweb.michael.orlitzky.com - spline3.git/blob - Cube.hs
a832f5a388eec53ca32131575a7f42c9b81c380e
[spline3.git] / Cube.hs
1 module Tests.Cube
2 where
3
4 import Test.QuickCheck
5
6 import Cube (Cube(Cube))
7 import FunctionValues (FunctionValues(FunctionValues))
8 import Tests.FunctionValues
9
10 instance Arbitrary Cube where
11 arbitrary = do
12 (Positive h') <- arbitrary :: Gen (Positive Double)
13 i' <- choose (coordmin, coordmax)
14 j' <- choose (coordmin, coordmax)
15 k' <- choose (coordmin, coordmax)
16 fv' <- arbitrary :: Gen FunctionValues
17 return (Cube h' i' j' k' fv')
18 where
19 coordmin = -268435456 -- -(2^29 / 2)
20 coordmax = 268435456 -- +(2^29 / 2)
21
22
23 -- Quickcheck tests.
24
25 -- | Since the grid size is necessarily positive, all tetrahedrons
26 -- (which comprise cubes of positive volume) must have positive volume
27 -- as well.
28 -- prop_all_volumes_positive :: Cube -> Property
29 -- prop_all_volumes_positive c =
30 -- (delta > 0) ==> (null nonpositive_volumes)
31 -- where
32 -- delta = h (grid c)
33 -- ts = tetrahedrons c
34 -- volumes = map volume ts
35 -- nonpositive_volumes = filter (<= 0) volumes