]> gitweb.michael.orlitzky.com - spline3.git/blobdiff - src/Tests/Cardinal.hs
Add a Cardinal test, computed manually and from Sorokina and Zeilfelder, p. 87.
[spline3.git] / src / Tests / Cardinal.hs
index 0d8d592e7d37a75c233547421c404fa03a53d380..450730da0b86eb849a8f8bc3110e9aee635516b0 100644 (file)
@@ -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,