From: Michael Orlitzky Date: Wed, 11 May 2011 21:49:35 +0000 (-0400) Subject: Add a Cardinal test, computed manually and from Sorokina and Zeilfelder, p. 87. X-Git-Tag: 0.0.1~290 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=ec2f7ca5bb3b0c41c62812cd725c62e731bb9902;p=spline3.git Add a Cardinal test, computed manually and from Sorokina and Zeilfelder, p. 87. --- diff --git a/src/Tests/Cardinal.hs b/src/Tests/Cardinal.hs index 0d8d592..450730d 100644 --- a/src/Tests/Cardinal.hs +++ b/src/Tests/Cardinal.hs @@ -3,6 +3,7 @@ where import Control.Monad (liftM, liftM2) import Prelude hiding (LT) +import Test.HUnit import Test.QuickCheck import Cardinal @@ -48,6 +49,34 @@ instance Arbitrary Cardinal where cquot = liftM2 Quotient arbitrary arbitrary +-- | We know what (c t6 2 1 0 0) should be from Sorokina and +-- Zeilfelder, p. 87. This test checks that the directions are +-- rotated properly. The order of the letters has to be just right +-- since I haven't defined a proper Eq instance for Cardinals. +test_c_tilde_2100_rotation_correct :: Test +test_c_tilde_2100_rotation_correct = + TestCase $ assertEqual "auto-rotate equals manual rotate" ((ccwz . ccwz . cwy) expr1) expr2 + where + expr1 = + (3/8)*I + + (1/12)*(T + R + L + D) + + (1/64)*(FT + FR + FL + FD) + + (7/48)*F + + (1/48)*B + + (1/96)*(RT + LD + LT + RD) + + (1/192)*(BT + BR + BL + BD) + + expr2 = + (3/8)*I + + (1/12)*(F + L + R + B) + + (1/64)*(FT + LT + RT + BT) + + (7/48)*T + + (1/48)*D + + (1/96)*(FL + BR + FR + BL) + + (1/192)*(FD + LD + RD + BD) + +cardinal_tests = [test_c_tilde_2100_rotation_correct] + -- | A list of all directions, sans the interior and composite types. all_directions :: [Cardinal] all_directions = [L, R, F, B, D, T, FL, FR, FD, FT, diff --git a/src/Tests/Cube.hs b/src/Tests/Cube.hs index 5846977..5a9ca19 100644 --- a/src/Tests/Cube.hs +++ b/src/Tests/Cube.hs @@ -537,7 +537,9 @@ prop_c1011_identity cube = -- t1 = tetrahedron1 cube + -- | We know what (c t6 2 1 0 0) should be from Sorokina and Zeilfelder, p. 87. +-- This test checks the actual value based on the FunctionValues of the cube. prop_c_tilde_2100_correct :: Cube -> Bool prop_c_tilde_2100_correct cube = c t6 2 1 0 0 == (3/8)*int + (1/12)*(f + r + l + b) + (1/64)*(ft + rt + lt + bt) diff --git a/test/TestSuite.hs b/test/TestSuite.hs index 951899f..ac1045b 100644 --- a/test/TestSuite.hs +++ b/test/TestSuite.hs @@ -9,7 +9,8 @@ import Tests.Misc import Tests.Tetrahedron as TT -- The list of HUnit tests. -test_suite = TestList (concat [function_values_tests, +test_suite = TestList (concat [cardinal_tests, + function_values_tests, grid_tests, misc_tests, tetrahedron_tests]) @@ -197,7 +198,7 @@ main = do putStr "prop_c2100_identity2... " quickCheckWith qc_args TC.prop_c2100_identity2 - putStrLn "\np. 79, (2.8)\n" + putStrLn "\np. 79, (2.8)\n" putStr "prop_c3000_identity... " quickCheckWith qc_args TC.prop_c3000_identity @@ -237,6 +238,10 @@ main = do -- putStr "prop_c0300_identity3... " -- quickCheckWith qc_args TF.prop_c0300_identity3 + putStrLn "prop_c_tilde_2100_correct... " + quickCheckWith qc_args prop_c_tilde_2100_correct + + putStrLn "\nEdge Incidence Tests\n" putStr "prop_t0_shares_edge_with_t6... "