~vaifrax/inkscape/bugfix170049

« back to all changes in this revision

Viewing changes to src/libnr/nr-rotate-fns-test.cpp

  • Committer: mental
  • Date: 2006-01-16 02:36:01 UTC
  • Revision ID: mental@users.sourceforge.net-20060116023601-wkr0h7edl5veyudq
moving trunk for module inkscape

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <cmath>
 
2
#include <glib/gmacros.h>
 
3
 
 
4
#include <libnr/nr-rotate-fns.h>
 
5
#include <utest/utest.h>
 
6
 
 
7
int main(int argc, char *argv[])
 
8
{
 
9
    utest_start("rotate-fns");
 
10
 
 
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));
 
20
 
 
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));
 
24
 
 
25
            UTEST_ASSERT(!rotate_equalp(rot, rotate_degrees(degrees + 1), 1e-5));
 
26
        }
 
27
    }
 
28
 
 
29
    return ( utest_end()
 
30
             ? EXIT_SUCCESS
 
31
             : EXIT_FAILURE );
 
32
}
 
33
 
 
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 :