]> gitweb.michael.orlitzky.com - spline3.git/blob - test/TestSuite.hs
A bunch more test cleanup.
[spline3.git] / test / TestSuite.hs
1 module TestSuite
2 where
3
4 import Test.Framework (defaultMain, testGroup, Test, TestName, TestOptions(..))
5 import Test.Framework.Providers.API (TestName)
6 import Test.Framework.Providers.DocTest
7 import Test.Framework.Providers.HUnit (testCase)
8 import Test.Framework.Providers.QuickCheck2 (testProperty)
9 import Test.HUnit
10 import Test.QuickCheck (Testable ())
11
12 import FunctionValues (function_values_tests, function_values_properties)
13 import Misc (misc_tests, misc_properties)
14 import Tests.Cardinal
15 import Tests.Cube as TC
16 import Tests.Grid
17 import Tests.Tetrahedron as TT
18
19 main :: IO ()
20 main = do
21 dt <- docTest ["src/Everything.hs"] ["-isrc"]
22 defaultMain $ [dt] ++ tests
23
24 -- | Defined so that my test names fit on one line.
25 tc :: Test.Framework.Providers.API.TestName -> Test.HUnit.Assertion -> Test.Framework.Test
26 tc = testCase
27
28 cardinal_tests :: Test.Framework.Test
29 cardinal_tests =
30 testGroup "Cardinal Tests" [
31 tc "c-tilde_2100 rotation correct" test_c_tilde_2100_rotation_correct ]
32
33
34 grid_tests :: Test.Framework.Test
35 grid_tests =
36 testGroup "Grid Tests" [
37 trilinear_c0_t0_tests,
38 tc "tetrahedra collision test isn't too sensitive"
39 test_tetrahedra_collision_sensitivity,
40 tc "trilinear reproduced" test_trilinear_reproduced,
41 tc "zeros reproduced" test_zeros_reproduced ]
42
43
44 tetrahedron_tests :: Test.Framework.Test
45 tetrahedron_tests =
46 testGroup "Tetrahedron Tests" [
47 tetrahedron1_geometry_tests,
48 tetrahedron2_geometry_tests,
49 containment_tests ]
50
51 -- | Defined so that my test names fit on one line.
52 tp :: Test.QuickCheck.Testable a => Test.Framework.TestName -> a -> Test.Framework.Test
53 tp = testProperty
54
55
56 cardinal_properties :: Test.Framework.Test
57 cardinal_properties =
58 testGroup "Cardinal Properties" [
59 tp "ccwx rotation changes direction" prop_ccwx_rotation_changes_direction,
60 tp "cwx rotation changes direction" prop_cwx_rotation_changes_direction,
61 tp "ccwy rotation changes direction" prop_ccwy_rotation_changes_direction,
62 tp "cwy rotation changes direction" prop_cwy_rotation_changes_direction,
63 tp "ccwz rotation changes direction" prop_ccwz_rotation_changes_direction,
64 tp "cwz rotation changes direction" prop_cwz_rotation_changes_direction,
65 tp "ccwx rotation result unique" prop_ccwx_rotation_result_unique,
66 tp "cwx rotation result unique" prop_cwx_rotation_result_unique,
67 tp "ccwy rotation result unique" prop_ccwy_rotation_result_unique,
68 tp "cwy rotation result unique" prop_cwy_rotation_result_unique,
69 tp "ccwz rotation result unique" prop_ccwz_rotation_result_unique,
70 tp "cwz rotation result unique" prop_cwz_rotation_result_unique,
71 tp "four cwx is identity" prop_four_cwx_is_identity,
72 tp "four ccwx is identity" prop_four_ccwx_is_identity,
73 tp "four cwy is identity" prop_four_cwy_is_identity,
74 tp "four ccwy is identity" prop_four_ccwy_is_identity,
75 tp "four cwz is identity" prop_four_cwz_is_identity,
76 tp "four ccwz is identity" prop_four_ccwz_is_identity]
77
78
79 p78_24_properties :: Test.Framework.Test
80 p78_24_properties =
81 testGroup "p. 78, Section (2.4) Properties" [
82 tp "c3000 identity" TT.prop_c3000_identity,
83 tp "c2100 identity" TT.prop_c2100_identity,
84 tp "c1110 identity" TT.prop_c1110_identity]
85
86 p78_25_properties :: Test.Framework.Test
87 p78_25_properties =
88 testGroup "p. 78, Section (2.5) Properties" [
89 tp "c_ijk1 identity" prop_cijk1_identity ]
90
91 edge_incidence_tests :: Test.Framework.Test
92 edge_incidence_tests =
93 testGroup "Edge Incidence Tests" [
94 tp "t0 shares edge with t6" prop_t0_shares_edge_with_t6,
95 tp "t0 shares edge with t1" prop_t0_shares_edge_with_t1,
96 tp "t0 shares edge with t3" prop_t0_shares_edge_with_t3,
97 tp "t1 shares edge with t2" prop_t1_shares_edge_with_t2,
98 tp "t1 shares edge with t19" prop_t1_shares_edge_with_t19,
99 tp "t2 shares edge with t3" prop_t2_shares_edge_with_t3,
100 tp "t2 shares edge with t12" prop_t2_shares_edge_with_t12,
101 tp "t3 shares edge with t21" prop_t3_shares_edge_with_t21,
102 tp "t4 shares edge with t5" prop_t4_shares_edge_with_t5,
103 tp "t4 shares edge with t7" prop_t4_shares_edge_with_t7,
104 tp "t4 shares edge with t10" prop_t4_shares_edge_with_t10,
105 tp "t5 shares edge with t6" prop_t5_shares_edge_with_t6,
106 tp "t5 shares edge with t16" prop_t5_shares_edge_with_t16,
107 tp "t6 shares edge with t7" prop_t6_shares_edge_with_t7,
108 tp "t7 shares edge with t20" prop_t7_shares_edge_with_t20 ]
109
110
111 p79_26_properties :: Test.Framework.Test
112 p79_26_properties =
113 testGroup "p. 79, Section (2.6) Properties" [
114 tp "c0120 identity1" TC.prop_c0120_identity1,
115 tp "c0120 identity2" TC.prop_c0120_identity2,
116 tp "c0120 identity3" TC.prop_c0120_identity3,
117 tp "c0120 identity4" TC.prop_c0120_identity4,
118 tp "c0120 identity5" TC.prop_c0120_identity5,
119 tp "c0120 identity6" TC.prop_c0120_identity6,
120 tp "c0120 identity7" TC.prop_c0120_identity7,
121 tp "c0210 identity1" TC.prop_c0210_identity1,
122 tp "c0300 identity1" TC.prop_c0300_identity1,
123 tp "c1110 identity" TC.prop_c1110_identity,
124 tp "c1200 identity1" TC.prop_c1200_identity1,
125 tp "c2100 identity1" TC.prop_c2100_identity1]
126
127 p79_27_properties :: Test.Framework.Test
128 p79_27_properties =
129 testGroup "p. 79, Section (2.7) Properties" [
130 tp "c0102 identity1" TC.prop_c0102_identity1,
131 tp "c0201 identity1" TC.prop_c0201_identity1,
132 tp "c0300 identity2" TC.prop_c0300_identity2,
133 tp "c1101 identity" TC.prop_c1101_identity,
134 tp "c1200 identity2" TC.prop_c1200_identity2,
135 tp "c2100 identity2" TC.prop_c2100_identity2 ]
136
137
138 p79_28_properties :: Test.Framework.Test
139 p79_28_properties =
140 testGroup "p. 79, Section (2.8) Properties" [
141 tp "c3000 identity" TC.prop_c3000_identity,
142 tp "c2010 identity" TC.prop_c2010_identity,
143 tp "c2001 identity" TC.prop_c2001_identity,
144 tp "c1020 identity" TC.prop_c1020_identity,
145 tp "c1002 identity" TC.prop_c1002_identity,
146 tp "c1011 identity" TC.prop_c1011_identity ]
147
148
149 cube_properties :: Test.Framework.Test
150 cube_properties =
151 testGroup "Cube Properties" [
152 tp "front/back tetrahedra are disjoint" prop_front_back_tetrahedra_disjoint,
153 tp "top/down tetrahedra are disjoint" prop_top_down_tetrahedra_disjoint,
154 tp "left/right tetrahedra are disjoint" prop_left_right_tetrahedra_disjoint,
155 tp "all volumes positive" prop_all_volumes_positive,
156 tp "all volumes exact" prop_all_volumes_exact,
157 tp "v0 all equal" prop_v0_all_equal,
158 tp "interior values all identical" prop_interior_values_all_identical,
159 tp "c-tilde_2100 rotation correct" prop_c_tilde_2100_rotation_correct,
160 tp "c-tilde_2100 correct" prop_c_tilde_2100_correct ]
161
162
163 tetrahedron_properties :: Test.Framework.Test
164 tetrahedron_properties =
165 testGroup "Tetrahedron Properties" [
166 tp "b0_v0_always_unity" prop_b0_v0_always_unity,
167 tp "b0_v1_always_zero" prop_b0_v1_always_zero,
168 tp "b0_v2_always_zero" prop_b0_v2_always_zero,
169 tp "b0_v3_always_zero" prop_b0_v3_always_zero,
170 tp "b1_v1_always_unity" prop_b1_v1_always_unity,
171 tp "b1_v0_always_zero" prop_b1_v0_always_zero,
172 tp "b1_v2_always_zero" prop_b1_v2_always_zero,
173 tp "b1_v3_always_zero" prop_b1_v3_always_zero,
174 tp "b2_v2_always_unity" prop_b2_v2_always_unity,
175 tp "b2_v0_always_zero" prop_b2_v0_always_zero,
176 tp "b2_v1_always_zero" prop_b2_v1_always_zero,
177 tp "b2_v3_always_zero" prop_b2_v3_always_zero,
178 tp "b3_v3_always_unity" prop_b3_v3_always_unity,
179 tp "b3_v0_always_zero" prop_b3_v0_always_zero,
180 tp "b3_v1_always_zero" prop_b3_v1_always_zero,
181 tp "b3_v2_always_zero" prop_b3_v2_always_zero,
182 tp "swapping_vertices_doesnt_affect_coefficients1"
183 $ prop_swapping_vertices_doesnt_affect_coefficients1,
184 tp "swapping_vertices_doesnt_affect_coefficients2"
185 $ prop_swapping_vertices_doesnt_affect_coefficients2,
186 tp "swapping_vertices_doesnt_affect_coefficients3"
187 $ prop_swapping_vertices_doesnt_affect_coefficients3,
188 tp "swapping_vertices_doesnt_affect_coefficients4"
189 $ prop_swapping_vertices_doesnt_affect_coefficients4 ]
190
191
192 -- Do the slow tests last so we can stop paying attention.
193 slow_tests :: Test.Framework.Test
194 slow_tests =
195 testGroup "Slow Tests" [
196 tp "cube indices within bounds" prop_cube_indices_never_go_out_of_bounds,
197 tc "trilinear9x9x9 reproduced" test_trilinear9x9x9_reproduced ]
198
199
200 tests :: [Test.Framework.Test]
201 tests = [ cardinal_tests,
202 function_values_tests,
203 grid_tests,
204 misc_tests,
205 tetrahedron_tests,
206 cube_properties,
207 tetrahedron_properties,
208 misc_properties,
209 cardinal_properties,
210 edge_incidence_tests,
211 p78_24_properties,
212 -- p78_25_properties,
213 p79_26_properties,
214 p79_27_properties,
215 p79_28_properties,
216 slow_tests ]