Code

Applied patch #1505715
[inkscape.git] / src / libnr / nr-rotate-fns-test.cpp
1 #include <cmath>
2 #include <glib/gmacros.h>
4 #include <libnr/nr-rotate-fns.h>
5 #include <utest/utest.h>
7 int main(int argc, char *argv[])
8 {
9     utest_start("rotate-fns");
11     UTEST_TEST("rotate_degrees") {
12         double const d[] = {
13             0, 90, 180, 270, 360, 45, 45.01, 44.99, 134, 135, 136, 314, 315, 317, 359, 361
14         };
15         for (unsigned i = 0; i < G_N_ELEMENTS(d); ++i) {
16             double const degrees = d[i];
17             NR::rotate const rot(rotate_degrees(degrees));
18             NR::rotate const rot_approx( M_PI * ( degrees / 180. ) );
19             UTEST_ASSERT(rotate_equalp(rot, rot_approx, 1e-12));
21             NR::rotate const rot_inv(rotate_degrees(-degrees));
22             NR::rotate const rot_compl(rotate_degrees(360 - degrees));
23             UTEST_ASSERT(rotate_equalp(rot_inv, rot_compl, 1e-12));
25             UTEST_ASSERT(!rotate_equalp(rot, rotate_degrees(degrees + 1), 1e-5));
26         }
27     }
29     return ( utest_end()
30              ? EXIT_SUCCESS
31              : EXIT_FAILURE );
32 }
34 /*
35   Local Variables:
36   mode:c++
37   c-file-style:"stroustrup"
38   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
39   indent-tabs-mode:nil
40   fill-column:99
41   End:
42 */
43 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :