From: Michael Orlitzky Date: Sat, 3 Sep 2011 20:54:53 +0000 (-0400) Subject: Move the FunctionValues tests into the FunctionValues module. X-Git-Tag: 0.0.1~171 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=1f20ae355d28b53fc2e1e31c4bd131e9ede00a87;p=spline3.git Move the FunctionValues tests into the FunctionValues module. --- diff --git a/src/FunctionValues.hs b/src/FunctionValues.hs index 895f925..00bb0a8 100644 --- a/src/FunctionValues.hs +++ b/src/FunctionValues.hs @@ -1,12 +1,25 @@ -- | The FunctionValues module contains the 'FunctionValues' type and -- the functions used to manipulate it. -module FunctionValues +module FunctionValues ( + FunctionValues, + empty_values, + eval, + make_values, + rotate, + function_values_tests, + value_at + ) where import Prelude hiding (LT) +import Test.HUnit +import Test.Framework (Test, testGroup) +import Test.Framework.Providers.HUnit (testCase) import Test.QuickCheck (Arbitrary(..), choose) -import Cardinal +import Assertions (assertTrue) +import Cardinal ( Cardinal(..) ) +import Examples (trilinear) import Values (Values3D, dims, idx) -- | The FunctionValues type represents the value of our function f at @@ -258,3 +271,46 @@ rotate rotation fv = back_right_down = eval fv (rotation BRD), back_right_top = eval fv (rotation BRT), interior = interior fv } + + + +-- | Ensure that the trilinear values wind up where we think they +-- should. +test_directions :: Assertion +test_directions = + assertTrue "all direction functions work" (and equalities) + where + fvs = make_values trilinear 1 1 1 + equalities = [ interior fvs == 4, + front fvs == 1, + back fvs == 7, + left fvs == 2, + right fvs == 6, + down fvs == 3, + top fvs == 5, + front_left fvs == 1, + front_right fvs == 1, + front_down fvs == 1, + front_top fvs == 1, + back_left fvs == 3, + back_right fvs == 11, + back_down fvs == 5, + back_top fvs == 9, + left_down fvs == 2, + left_top fvs == 2, + right_down fvs == 4, + right_top fvs == 8, + front_left_down fvs == 1, + front_left_top fvs == 1, + front_right_down fvs == 1, + front_right_top fvs == 1, + back_left_down fvs == 3, + back_left_top fvs == 3, + back_right_down fvs == 7, + back_right_top fvs == 15] + + +function_values_tests :: Test.Framework.Test +function_values_tests = + testGroup "FunctionValues Tests" + [ testCase "test directions" test_directions ] diff --git a/src/Tests/Cube.hs b/src/Tests/Cube.hs index 0a1cc50..17ea7f8 100644 --- a/src/Tests/Cube.hs +++ b/src/Tests/Cube.hs @@ -8,7 +8,6 @@ import Comparisons import Cube hiding (i, j, k) import FunctionValues import Misc (all_equal, disjoint) -import Tests.FunctionValues () import Tetrahedron (b0, b1, b2, b3, c, fv, v0, v1, v2, v3, volume) @@ -412,25 +411,35 @@ prop_c_tilde_2100_correct cube = t0 = tetrahedron0 cube t6 = tetrahedron6 cube fvs = Tetrahedron.fv t0 - int = interior fvs - f = front fvs - r = right fvs - l = left fvs - b = back fvs - ft = front_top fvs - rt = right_top fvs - lt = left_top fvs - bt = back_top fvs - t = top fvs - d = down fvs - fr = front_right fvs - fl = front_left fvs - br = back_right fvs - bl = back_left fvs - fd = front_down fvs - rd = right_down fvs - ld = left_down fvs - bd = back_down fvs + (Cube _ i j k _ _) = cube + f = value_at fvs (i-1) j k + b = value_at fvs (i+1) j k + l = value_at fvs i (j-1) k + r = value_at fvs i (j+1) k + d = value_at fvs i j (k-1) + t = value_at fvs i j (k+1) + fl = value_at fvs (i-1) (j-1) k + fr = value_at fvs (i-1) (j+1) k + fd = value_at fvs (i-1) j (k-1) + ft = value_at fvs (i-1) j (k+1) + bl = value_at fvs (i+1) (j-1) k + br = value_at fvs (i+1) (j+1) k + bd = value_at fvs (i+1) j (k-1) + bt = value_at fvs (i+1) j (k+1) + ld = value_at fvs i (j-1) (k-1) + lt = value_at fvs i (j-1) (k+1) + rd = value_at fvs i (j+1) (k-1) + rt = value_at fvs i (j+1) (k+1) + fld = value_at fvs (i-1) (j-1) (k-1) + flt = value_at fvs (i-1) (j-1) (k+1) + frd = value_at fvs (i-1) (j+1) (k-1) + frt = value_at fvs (i-1) (j+1) (k+1) + bld = value_at fvs (i+1) (j-1) (k-1) + blt = value_at fvs (i+1) (j-1) (k+1) + brd = value_at fvs (i+1) (j+1) (k-1) + brt = value_at fvs (i+1) (j+1) (k+1) + int = value_at fvs i j k + -- Tests to check that the correct edges are incidental. prop_t0_shares_edge_with_t1 :: Cube -> Bool diff --git a/src/Tests/FunctionValues.hs b/src/Tests/FunctionValues.hs deleted file mode 100644 index 9cada35..0000000 --- a/src/Tests/FunctionValues.hs +++ /dev/null @@ -1,41 +0,0 @@ -module Tests.FunctionValues -where - -import Test.HUnit - -import Assertions -import Examples -import FunctionValues - -test_directions :: Assertion -test_directions = - assertTrue "all direction functions work" (and equalities) - where - fvs = make_values trilinear 1 1 1 - equalities = [ interior fvs == 4, - front fvs == 1, - back fvs == 7, - left fvs == 2, - right fvs == 6, - down fvs == 3, - top fvs == 5, - front_left fvs == 1, - front_right fvs == 1, - front_down fvs == 1, - front_top fvs == 1, - back_left fvs == 3, - back_right fvs == 11, - back_down fvs == 5, - back_top fvs == 9, - left_down fvs == 2, - left_top fvs == 2, - right_down fvs == 4, - right_top fvs == 8, - front_left_down fvs == 1, - front_left_top fvs == 1, - front_right_down fvs == 1, - front_right_top fvs == 1, - back_left_down fvs == 3, - back_left_top fvs == 3, - back_right_down fvs == 7, - back_right_top fvs == 15] diff --git a/src/Tests/Tetrahedron.hs b/src/Tests/Tetrahedron.hs index 3b511d2..ec71e3b 100644 --- a/src/Tests/Tetrahedron.hs +++ b/src/Tests/Tetrahedron.hs @@ -9,7 +9,6 @@ import Test.QuickCheck (Property, (==>)) import Cardinal import Comparisons import FunctionValues -import Tests.FunctionValues() import Tetrahedron import ThreeDimensional diff --git a/test/TestSuite.hs b/test/TestSuite.hs index 66f592b..73723c2 100644 --- a/test/TestSuite.hs +++ b/test/TestSuite.hs @@ -9,9 +9,9 @@ import Test.Framework.Providers.QuickCheck2 (testProperty) import Test.HUnit import Test.QuickCheck (Testable ()) +import FunctionValues (functionvalues_tests) import Tests.Cardinal import Tests.Cube as TC -import Tests.FunctionValues import Tests.Grid import Tests.Misc import Tests.Tetrahedron as TT @@ -30,9 +30,6 @@ cardinal_tests = testGroup "Cardinal Tests" [ tc "c-tilde_2100 rotation correct" test_c_tilde_2100_rotation_correct ] -function_values_tests :: Test.Framework.Test -function_values_tests = - testGroup "FunctionValues Tests" [ tc "test directions" test_directions ] grid_tests :: Test.Framework.Test grid_tests =