import Test.Framework (Test, testGroup)
import Test.Framework.Providers.HUnit (testCase)
import Test.HUnit
+import Test.QuickCheck
+
import Assertions
import Comparisons
import Point (Point)
import Tetrahedron
import ThreeDimensional
+import Values (dims)
-- | Check all coefficients of tetrahedron0 belonging to the cube
-- | Make sure we can reproduce a 9x9x9 trilinear from the 3x3x3 one.
--- Use (t <- tetrahedra c0) for a much slower but comprehensive
--- test.
test_trilinear9x9x9_reproduced :: Assertion
test_trilinear9x9x9_reproduced =
assertTrue "trilinear 9x9x9 is reproduced correctly" $
| i <- [0..8],
j <- [0..8],
k <- [0..8],
- t <- [head $ tetrahedra c0],
+ t <- tetrahedra c0,
let p = polynomial t,
let i' = (fromIntegral i) * 0.5,
let j' = (fromIntegral j) * 0.5,
c = cube_at g 0 17 1
p = (0, 16.75, 0.5) :: Point
t15 = tetrahedron15 c
+
+
+prop_cube_indices_never_go_out_of_bounds :: Grid -> Gen Bool
+prop_cube_indices_never_go_out_of_bounds g =
+ do
+ let delta = Grid.h g
+ let coordmin = negate (delta/2)
+
+ let (xsize, ysize, zsize) = dims $ function_values g
+ let xmax = delta*(fromIntegral xsize) - (delta/2)
+ let ymax = delta*(fromIntegral ysize) - (delta/2)
+ let zmax = delta*(fromIntegral zsize) - (delta/2)
+
+ x <- choose (coordmin, xmax)
+ y <- choose (coordmin, ymax)
+ z <- choose (coordmin, zmax)
+
+ let p = (x,y,z) :: Point
+ let idx_x = calculate_containing_cube_coordinate g x
+ let idx_y = calculate_containing_cube_coordinate g y
+ let idx_z = calculate_containing_cube_coordinate g z
+
+ return $
+ idx_x >= 0 &&
+ idx_x <= xsize - 1 &&
+ idx_y >= 0 &&
+ idx_y <= ysize - 1 &&
+ idx_z >= 0 &&
+ idx_z <= zsize - 1