~vaifrax/inkscape/bugfix170049

« back to all changes in this revision

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

  • 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 <cxxtest/TestSuite.h>
 
2
 
 
3
#include <cmath>
 
4
#include <glib/gmacros.h>
 
5
 
 
6
#include <libnr/nr-rotate-fns.h>
 
7
 
 
8
class NrRotateFnsTest : public CxxTest::TestSuite
 
9
{
 
10
public:
 
11
 
 
12
    NrRotateFnsTest()
 
13
    {
 
14
    }
 
15
    virtual ~NrRotateFnsTest() {}
 
16
 
 
17
// createSuite and destroySuite get us per-suite setup and teardown
 
18
// without us having to worry about static initialization order, etc.
 
19
    static NrRotateFnsTest *createSuite() { return new NrRotateFnsTest(); }
 
20
    static void destroySuite( NrRotateFnsTest *suite ) { delete suite; }
 
21
 
 
22
 
 
23
 
 
24
    void testRotateDegrees(void)
 
25
    {
 
26
        double const d[] = {
 
27
            0, 90, 180, 270, 360, 45, 45.01, 44.99, 134, 135, 136, 314, 315, 317, 359, 361
 
28
        };
 
29
        for ( unsigned i = 0; i < G_N_ELEMENTS(d); ++i ) {
 
30
            double const degrees = d[i];
 
31
            NR::rotate const rot(rotate_degrees(degrees));
 
32
            NR::rotate const rot_approx( M_PI * ( degrees / 180. ) );
 
33
            TS_ASSERT( rotate_equalp(rot, rot_approx, 1e-12) );
 
34
 
 
35
            NR::rotate const rot_inv(rotate_degrees(-degrees));
 
36
            NR::rotate const rot_compl(rotate_degrees(360 - degrees));
 
37
            TS_ASSERT( rotate_equalp(rot_inv, rot_compl, 1e-12) );
 
38
 
 
39
            TS_ASSERT( !rotate_equalp(rot, rotate_degrees(degrees + 1), 1e-5) );
 
40
        }
 
41
    }
 
42
 
 
43
};
 
44
 
 
45
/*
 
46
  Local Variables:
 
47
  mode:c++
 
48
  c-file-style:"stroustrup"
 
49
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
 
50
  indent-tabs-mode:nil
 
51
  fill-column:99
 
52
  End:
 
53
*/
 
54
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :