]> gitweb.michael.orlitzky.com - spline3.git/blob - TestSuite.hs
abe2275b7ea87c8ec14c3c841f8865629a3ffeed
[spline3.git] / 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.HUnit (testCase)
7 import Test.Framework.Providers.QuickCheck2 (testProperty)
8 import Test.HUnit
9 import Test.QuickCheck (Testable ())
10
11 import Tests.Cardinal
12 import Tests.Cube as TC
13 import Tests.FunctionValues
14 import Tests.Grid
15 import Tests.Misc
16 import Tests.Tetrahedron as TT
17
18 main :: IO ()
19 main = defaultMain tests
20
21 -- | Defined so that my test names fit on one line.
22 tc :: Test.Framework.Providers.API.TestName -> Test.HUnit.Assertion -> Test.Framework.Test
23 tc = testCase
24
25 cardinal_tests :: Test.Framework.Test
26 cardinal_tests =
27 testGroup "Cardinal Tests" [
28 tc "c-tilde_2100 rotation correct" test_c_tilde_2100_rotation_correct ]
29
30 function_values_tests :: Test.Framework.Test
31 function_values_tests =
32 testGroup "FunctionValues Tests" [ tc "test directions" test_directions ]
33
34 grid_tests :: Test.Framework.Test
35 grid_tests =
36 testGroup "Grid Tests" [
37 tc "trilinear c0030" test_trilinear_c0030,
38 tc "trilinear c0003" test_trilinear_c0003,
39 tc "trilinear c0021" test_trilinear_c0021,
40 tc "trilinear c0012" test_trilinear_c0012,
41 tc "trilinear c0120" test_trilinear_c0120,
42 tc "trilinear c0102" test_trilinear_c0102,
43 tc "trilinear c0111" test_trilinear_c0111,
44 tc "trilinear c0210" test_trilinear_c0210,
45 tc "trilinear c0201" test_trilinear_c0201,
46 tc "trilinear c0300" test_trilinear_c0300,
47 tc "trilinear c1020" test_trilinear_c1020,
48 tc "trilinear c1002" test_trilinear_c1002,
49 tc "trilinear c1011" test_trilinear_c1011,
50 tc "trilinear c1110" test_trilinear_c1110,
51 tc "trilinear c1101" test_trilinear_c1101,
52 tc "trilinear c1200" test_trilinear_c1200,
53 tc "trilinear c2010" test_trilinear_c2010,
54 tc "trilinear c2001" test_trilinear_c2001,
55 tc "trilinear c2100" test_trilinear_c2100,
56 tc "trilinear c3000" test_trilinear_c3000,
57 tc "trilinear f0_t0_v0" test_trilinear_f0_t0_v0,
58 tc "trilinear f0_t0_v1" test_trilinear_f0_t0_v1,
59 tc "trilinear f0_t0_v2" test_trilinear_f0_t0_v2,
60 tc "trilinear f0_t0_v3" test_trilinear_f0_t0_v3,
61 tc "trilinear reproduced" test_trilinear_reproduced,
62 tc "zeros reproduced" test_zeros_reproduced ]
63
64
65 misc_tests :: Test.Framework.Test
66 misc_tests =
67 testGroup "Misc Tests" [
68 tc "flatten (1)" test_flatten1 ]
69
70 tetrahedron_tests :: Test.Framework.Test
71 tetrahedron_tests =
72 testGroup "Tetrahedron Tests" [
73 tc "volume (1)" test_volume1,
74 tc "volume (2)" test_volume2,
75 tc "contains point (1)" test_contains_point1,
76 tc "doesn't contain point (1)" test_doesnt_contain_point1,
77 tc "doesn't contain point (2)" test_doesnt_contain_point2,
78 tc "doesn't contain point (3)" test_doesnt_contain_point3,
79 tc "doesn't contain point (4)" test_doesnt_contain_point4,
80 tc "doesn't contain point (5)" test_doesnt_contain_point5 ]
81
82 -- | Defined so that my test names fit on one line.
83 tp :: Test.QuickCheck.Testable a => Test.Framework.TestName -> a -> Test.Framework.Test
84 tp = testProperty
85
86 misc_properties :: Test.Framework.Test
87 misc_properties =
88 testGroup "Misc Properties" [
89 tp "factorial greater" prop_factorial_greater ]
90
91 cardinal_properties :: Test.Framework.Test
92 cardinal_properties =
93 testGroup "Cardinal Properties" [
94 tp "ccwx rotation changes direction" prop_ccwx_rotation_changes_direction,
95 tp "cwx rotation changes direction" prop_cwx_rotation_changes_direction,
96 tp "ccwy rotation changes direction" prop_ccwy_rotation_changes_direction,
97 tp "cwy rotation changes direction" prop_cwy_rotation_changes_direction,
98 tp "ccwz rotation changes direction" prop_ccwz_rotation_changes_direction,
99 tp "cwz rotation changes direction" prop_cwz_rotation_changes_direction,
100 tp "ccwx rotation result unique" prop_ccwx_rotation_result_unique,
101 tp "cwx rotation result unique" prop_cwx_rotation_result_unique,
102 tp "ccwy rotation result unique" prop_ccwy_rotation_result_unique,
103 tp "cwy rotation result unique" prop_cwy_rotation_result_unique,
104 tp "ccwz rotation result unique" prop_ccwz_rotation_result_unique,
105 tp "cwz rotation result unique" prop_cwz_rotation_result_unique,
106 tp "four cwx is identity" prop_four_cwx_is_identity,
107 tp "four ccwx is identity" prop_four_ccwx_is_identity,
108 tp "four cwy is identity" prop_four_cwy_is_identity,
109 tp "four ccwy is identity" prop_four_ccwy_is_identity,
110 tp "four cwz is identity" prop_four_cwz_is_identity,
111 tp "four ccwz is identity" prop_four_ccwz_is_identity]
112
113
114 p78_24_properties :: Test.Framework.Test
115 p78_24_properties =
116 testGroup "p. 78, Section (2.4) Properties" [
117 tp "c3000 identity" TT.prop_c3000_identity,
118 tp "c2100 identity" TT.prop_c2100_identity,
119 tp "c1110 _identity" TT.prop_c1110_identity]
120
121 p78_25_properties :: Test.Framework.Test
122 p78_25_properties =
123 testGroup "p. 78, Section (2.5) Properties" [
124 tp "c_ijk1 identity" prop_cijk1_identity ]
125
126 edge_incidence_tests :: Test.Framework.Test
127 edge_incidence_tests =
128 testGroup "Edge Incidence Tests" [
129 tp "t0 shares edge with t6" prop_t0_shares_edge_with_t6,
130 tp "t0 shares edge with t1" prop_t0_shares_edge_with_t1,
131 tp "t0 shares edge with t3" prop_t0_shares_edge_with_t3,
132 tp "t1 shares edge with t2" prop_t1_shares_edge_with_t2,
133 tp "t1 shares edge with t19" prop_t1_shares_edge_with_t19,
134 tp "t2 shares edge with t3" prop_t2_shares_edge_with_t3,
135 tp "t2 shares edge with t12" prop_t2_shares_edge_with_t12,
136 tp "t3 shares edge with t21" prop_t3_shares_edge_with_t21,
137 tp "t4 shares edge with t5" prop_t4_shares_edge_with_t5,
138 tp "t4 shares edge with t7" prop_t4_shares_edge_with_t7,
139 tp "t4 shares edge with t10" prop_t4_shares_edge_with_t10,
140 tp "t5 shares edge with t6" prop_t5_shares_edge_with_t6,
141 tp "t5 shares edge with t16" prop_t5_shares_edge_with_t16,
142 tp "t6 shares edge with t7" prop_t6_shares_edge_with_t7,
143 tp "t7 shares edge with t20" prop_t7_shares_edge_with_t20 ]
144
145
146 p79_26_properties :: Test.Framework.Test
147 p79_26_properties =
148 testGroup "p. 79, Section (2.6) Properties" [
149 tp "c0120 identity1" TC.prop_c0120_identity1,
150 tp "c0120 identity2" TC.prop_c0120_identity2,
151 tp "c0120 identity3" TC.prop_c0120_identity3,
152 --
153 -- These repeats of the previous test are failing at the moment.
154 --
155 -- tp "c0120 identity4" TC.prop_c0120_identity4,
156 -- tp "c0120 identity5" TC.prop_c0120_identity5,
157 -- tp "c0120 identity6" TC.prop_c0120_identity6,
158 tp "c0210 identity1" TC.prop_c0210_identity1,
159 tp "c0300 identity1" TC.prop_c0300_identity1,
160 tp "c1110 identity" TC.prop_c1110_identity,
161 tp "c1200 identity1" TC.prop_c1200_identity1,
162 tp "c2100 identity1" TC.prop_c2100_identity1]
163
164 p79_27_properties :: Test.Framework.Test
165 p79_27_properties =
166 testGroup "p. 79, Section (2.7) Properties" [
167 tp "c0102 identity1" TC.prop_c0102_identity1,
168 tp "c0201 identity1" TC.prop_c0201_identity1,
169 tp "c0300 identity2" TC.prop_c0300_identity2,
170 tp "c1101 identity" TC.prop_c1101_identity,
171 tp "c1200 identity2" TC.prop_c1200_identity2,
172 tp "c2100 identity2" TC.prop_c2100_identity2 ]
173
174
175 p79_28_properties :: Test.Framework.Test
176 p79_28_properties =
177 testGroup "p. 79, Section (2.8) Properties" [
178 tp "c3000 identity" TC.prop_c3000_identity,
179 tp "c2010 identity" TC.prop_c2010_identity,
180 tp "c2001 identity" TC.prop_c2001_identity,
181 tp "c1020 identity" TC.prop_c1020_identity,
182 tp "c1002 identity" TC.prop_c1002_identity,
183 tp "c1011 identity" TC.prop_c1011_identity ]
184
185
186 cube_properties :: Test.Framework.Test
187 cube_properties =
188 testGroup "Cube Properties" [
189 tp "all volumes positive" prop_all_volumes_positive,
190 tp "tetrahedron0 volumes exact" prop_tetrahedron0_volumes_exact,
191 tp "tetrahedron1 volumes exact" prop_tetrahedron1_volumes_exact,
192 tp "tetrahedron2 volumes exact" prop_tetrahedron2_volumes_exact,
193 tp "tetrahedron3 volumes exact" prop_tetrahedron3_volumes_exact,
194 tp "tetrahedron4 volumes exact" prop_tetrahedron4_volumes_exact,
195 tp "tetrahedron5 volumes exact" prop_tetrahedron5_volumes_exact,
196 tp "tetrahedron6 volumes exact" prop_tetrahedron6_volumes_exact,
197 tp "tetrahedron7 volumes exact" prop_tetrahedron7_volumes_exact,
198 tp "tetrahedron8 volumes exact" prop_tetrahedron8_volumes_exact,
199 tp "tetrahedron9 volumes exact" prop_tetrahedron9_volumes_exact,
200 tp "tetrahedron10 volumes exact" prop_tetrahedron10_volumes_exact,
201 tp "tetrahedron11 volumes exact" prop_tetrahedron11_volumes_exact,
202 tp "tetrahedron12 volumes exact" prop_tetrahedron12_volumes_exact,
203 tp "tetrahedron13 volumes exact" prop_tetrahedron13_volumes_exact,
204 tp "tetrahedron14 volumes exact" prop_tetrahedron14_volumes_exact,
205 tp "tetrahedron15 volumes exact" prop_tetrahedron15_volumes_exact,
206 tp "tetrahedron16 volumes exact" prop_tetrahedron16_volumes_exact,
207 tp "tetrahedron17 volumes exact" prop_tetrahedron17_volumes_exact,
208 tp "tetrahedron18 volumes exact" prop_tetrahedron18_volumes_exact,
209 tp "tetrahedron19 volumes exact" prop_tetrahedron19_volumes_exact,
210 tp "tetrahedron20 volumes exact" prop_tetrahedron20_volumes_exact,
211 tp "tetrahedron21 volumes exact" prop_tetrahedron21_volumes_exact,
212 tp "tetrahedron22 volumes exact" prop_tetrahedron22_volumes_exact,
213 tp "tetrahedron23 volumes exact" prop_tetrahedron23_volumes_exact,
214 tp "tetrahedron0 volumes positive" prop_tetrahedron0_volumes_positive,
215 tp "tetrahedron1 volumes positive" prop_tetrahedron1_volumes_positive,
216 tp "tetrahedron2 volumes positive" prop_tetrahedron2_volumes_positive,
217 tp "tetrahedron3 volumes positive" prop_tetrahedron3_volumes_positive,
218 tp "tetrahedron4 volumes positive" prop_tetrahedron4_volumes_positive,
219 tp "tetrahedron5 volumes positive" prop_tetrahedron5_volumes_positive,
220 tp "tetrahedron6 volumes positive" prop_tetrahedron6_volumes_positive,
221 tp "tetrahedron7 volumes positive" prop_tetrahedron7_volumes_positive,
222 tp "tetrahedron8 volumes positive" prop_tetrahedron8_volumes_positive,
223 tp "tetrahedron9 volumes positive" prop_tetrahedron9_volumes_positive,
224 tp "tetrahedron10 volumes positive" prop_tetrahedron10_volumes_positive,
225 tp "tetrahedron11 volumes positive" prop_tetrahedron11_volumes_positive,
226 tp "tetrahedron12 volumes positive" prop_tetrahedron12_volumes_positive,
227 tp "tetrahedron13 volumes positive" prop_tetrahedron13_volumes_positive,
228 tp "tetrahedron14 volumes positive" prop_tetrahedron14_volumes_positive,
229 tp "tetrahedron15 volumes positive" prop_tetrahedron15_volumes_positive,
230 tp "tetrahedron16 volumes positive" prop_tetrahedron16_volumes_positive,
231 tp "tetrahedron17 volumes positive" prop_tetrahedron17_volumes_positive,
232 tp "tetrahedron18 volumes positive" prop_tetrahedron18_volumes_positive,
233 tp "tetrahedron19 volumes positive" prop_tetrahedron19_volumes_positive,
234 tp "tetrahedron20 volumes positive" prop_tetrahedron20_volumes_positive,
235 tp "tetrahedron21 volumes positive" prop_tetrahedron21_volumes_positive,
236 tp "tetrahedron22 volumes positive" prop_tetrahedron22_volumes_positive,
237 tp "tetrahedron23 volumes positive" prop_tetrahedron23_volumes_positive,
238 tp "v0 all equal" prop_v0_all_equal,
239 tp "interior values all identical" prop_interior_values_all_identical,
240 tp "c-tilde_2100 rotation correct" prop_c_tilde_2100_rotation_correct,
241 tp "c-tilde_2100 correct" prop_c_tilde_2100_correct ]
242
243
244 tetrahedron_properties :: Test.Framework.Test
245 tetrahedron_properties =
246 testGroup "Tetrahedron Properties" [
247 tp "b0_v0_always_unity" prop_b0_v0_always_unity,
248 tp "b0_v1_always_zero" prop_b0_v1_always_zero,
249 tp "b0_v2_always_zero" prop_b0_v2_always_zero,
250 tp "b0_v3_always_zero" prop_b0_v3_always_zero,
251 tp "b1_v1_always_unity" prop_b1_v1_always_unity,
252 tp "b1_v0_always_zero" prop_b1_v0_always_zero,
253 tp "b1_v2_always_zero" prop_b1_v2_always_zero,
254 tp "b1_v3_always_zero" prop_b1_v3_always_zero,
255 tp "b2_v2_always_unity" prop_b2_v2_always_unity,
256 tp "b2_v0_always_zero" prop_b2_v0_always_zero,
257 tp "b2_v1_always_zero" prop_b2_v1_always_zero,
258 tp "b2_v3_always_zero" prop_b2_v3_always_zero,
259 tp "b3_v3_always_unity" prop_b3_v3_always_unity,
260 tp "b3_v0_always_zero" prop_b3_v0_always_zero,
261 tp "b3_v1_always_zero" prop_b3_v1_always_zero,
262 tp "b3_v2_always_zero" prop_b3_v2_always_zero,
263 tp "swapping_vertices_doesnt_affect_coefficients1"
264 $ prop_swapping_vertices_doesnt_affect_coefficients1,
265 tp "swapping_vertices_doesnt_affect_coefficients2"
266 $ prop_swapping_vertices_doesnt_affect_coefficients2,
267 tp "swapping_vertices_doesnt_affect_coefficients3"
268 $ prop_swapping_vertices_doesnt_affect_coefficients3,
269 tp "swapping_vertices_doesnt_affect_coefficients4"
270 $ prop_swapping_vertices_doesnt_affect_coefficients4,
271 tp "x rotation doesn't affect front" prop_x_rotation_doesnt_affect_front,
272 tp "x rotation doesn't affect back" prop_x_rotation_doesnt_affect_back,
273 tp "y rotation doesn't affect left" prop_y_rotation_doesnt_affect_left,
274 tp "y rotation doesn't affect right" prop_y_rotation_doesnt_affect_right,
275 tp "z rotation doesn't affect top" prop_z_rotation_doesnt_affect_top,
276 tp "z rotation doesn't affect down" prop_z_rotation_doesnt_affect_down ]
277
278 tests :: [Test.Framework.Test]
279 tests = [ cardinal_tests,
280 function_values_tests,
281 grid_tests,
282 misc_tests,
283 tetrahedron_tests,
284 cube_properties,
285 tetrahedron_properties,
286 misc_properties,
287 cardinal_properties,
288 edge_incidence_tests,
289 p78_24_properties,
290 -- p78_25_properties,
291 p79_26_properties,
292 p79_27_properties,
293 p79_28_properties ]