7 import FunctionValues (FunctionValues(FunctionValues))
8 import Tests.FunctionValues
9 import Tetrahedron (v0, volume)
11 instance Arbitrary Cube where
13 (Positive h') <- arbitrary :: Gen (Positive Double)
14 i' <- choose (coordmin, coordmax)
15 j' <- choose (coordmin, coordmax)
16 k' <- choose (coordmin, coordmax)
17 fv' <- arbitrary :: Gen FunctionValues
18 return (Cube h' i' j' k' fv')
20 coordmin = -268435456 -- -(2^29 / 2)
21 coordmax = 268435456 -- +(2^29 / 2)
26 -- | Since the grid size is necessarily positive, all tetrahedrons
27 -- (which comprise cubes of positive volume) must have positive volume
29 prop_all_volumes_positive :: Cube -> Property
30 prop_all_volumes_positive c =
31 (delta > 0) ==> (null nonpositive_volumes)
35 volumes = map volume ts
36 nonpositive_volumes = filter (<= 0) volumes
38 -- | All tetrahedron should have their v0 located at the center of the cube.
39 prop_v0_all_equal :: Cube -> Bool
40 prop_v0_all_equal c = (v0 t0) == (v0 t1)
42 t0 = head (tetrahedrons c) -- Doesn't matter which two we choose.
43 t1 = head $ tail (tetrahedrons c)
46 -- | This pretty much repeats the prop_all_volumes_positive property,
47 -- but will let me know which face's vertices are disoriented.
48 prop_front_face_volumes_positive :: Cube -> Property
49 prop_front_face_volumes_positive c =
50 (delta > 0) ==> (null nonpositive_volumes)
53 ts = [tetrahedron0 c, tetrahedron1 c, tetrahedron2 c, tetrahedron3 c]
54 volumes = map volume ts
55 nonpositive_volumes = filter (<= 0) volumes
58 -- | This pretty much repeats the prop_all_volumes_positive property,
59 -- but will let me know which face's vertices are disoriented.
60 prop_top_face_volumes_positive :: Cube -> Property
61 prop_top_face_volumes_positive c =
62 (delta > 0) ==> (null nonpositive_volumes)
65 ts = [tetrahedron4 c, tetrahedron5 c, tetrahedron6 c, tetrahedron7 c]
66 volumes = map volume ts
67 nonpositive_volumes = filter (<= 0) volumes