From 86d39fb9ddd83414f4b896bea89404e9786ff0d0 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Thu, 1 Sep 2011 13:02:23 -0400 Subject: [PATCH] Add tests for some functions used in the new 'find_containing_tetrahedron'. --- src/Tests/Cube.hs | 24 ++++++++++++++++++++++-- test/TestSuite.hs | 3 +++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/Tests/Cube.hs b/src/Tests/Cube.hs index 15103ce..0a1cc50 100644 --- a/src/Tests/Cube.hs +++ b/src/Tests/Cube.hs @@ -7,15 +7,35 @@ import Cardinal import Comparisons import Cube hiding (i, j, k) import FunctionValues -import Misc (all_equal) +import Misc (all_equal, disjoint) import Tests.FunctionValues () import Tetrahedron (b0, b1, b2, b3, c, fv, v0, v1, v2, v3, volume) - -- Quickcheck tests. +-- | The 'front_half_tetrahedra' and 'back_half_tetrahedra' should +-- have no tetrahedra in common. +prop_front_back_tetrahedra_disjoint :: Cube -> Bool +prop_front_back_tetrahedra_disjoint c = + disjoint (front_half_tetrahedra c) (back_half_tetrahedra c) + + +-- | The 'top_half_tetrahedra' and 'down_half_tetrahedra' should +-- have no tetrahedra in common. +prop_top_down_tetrahedra_disjoint :: Cube -> Bool +prop_top_down_tetrahedra_disjoint c = + disjoint (top_half_tetrahedra c) (down_half_tetrahedra c) + + +-- | The 'left_half_tetrahedra' and 'right_half_tetrahedra' should +-- have no tetrahedra in common. +prop_left_right_tetrahedra_disjoint :: Cube -> Bool +prop_left_right_tetrahedra_disjoint c = + disjoint (left_half_tetrahedra c) (right_half_tetrahedra c) + + -- | Since the grid size is necessarily positive, all tetrahedra -- (which comprise cubes of positive volume) must have positive volume -- as well. diff --git a/test/TestSuite.hs b/test/TestSuite.hs index 541694c..82e2870 100644 --- a/test/TestSuite.hs +++ b/test/TestSuite.hs @@ -162,6 +162,9 @@ p79_28_properties = cube_properties :: Test.Framework.Test cube_properties = testGroup "Cube Properties" [ + tp "front/back tetrahedra are disjoint" prop_front_back_tetrahedra_disjoint, + tp "top/down tetrahedra are disjoint" prop_top_down_tetrahedra_disjoint, + tp "left/right tetrahedra are disjoint" prop_left_right_tetrahedra_disjoint, tp "all volumes positive" prop_all_volumes_positive, tp "all volumes exact" prop_all_volumes_exact, tp "v0 all equal" prop_v0_all_equal, -- 2.43.2