+
+
+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