2 #ifndef SEEN_MOD_360_TEST_H
3 #define SEEN_MOD_360_TEST_H
5 #include <cxxtest/TestSuite.h>
7 #include <isnan.h>
9 #include "mod360.h"
12 class Mod360Test : public CxxTest::TestSuite
13 {
14 public:
15 static double const inf() { return INFINITY; }
16 static double nan() { return ((double)INFINITY) - ((double)INFINITY); }
18 void testMod360()
19 {
20 double cases[][2] = {
21 {0, 0},
22 {10, 10},
23 {360, 0},
24 {361, 1},
25 {-1, 359},
26 {-359, 1},
27 {-360, -0},
28 {-361, 359},
29 {inf(), 0},
30 {-inf(), 0},
31 {nan(), 0},
32 {720, 0},
33 {-721, 359},
34 {-1000, 80}
35 };
37 for ( unsigned i = 0; i < G_N_ELEMENTS(cases); i++ ) {
38 double result = mod360( cases[i][0] );
39 TS_ASSERT_EQUALS( cases[i][1], result );
40 }
41 }
43 };
46 #endif // SEEN_MOD_360_TEST_H
48 /*
49 Local Variables:
50 mode:c++
51 c-file-style:"stroustrup"
52 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
53 indent-tabs-mode:nil
54 fill-column:99
55 End:
56 */
57 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :