Code

Disable the page selector when there's only one page
[inkscape.git] / src / libnr / nr-translate-test.h
1 #include <cxxtest/TestSuite.h>
3 #include <libnr/nr-point-ops.h>
4 #include <libnr/nr-matrix.h>
5 #include <libnr/nr-matrix-fns.h>
6 #include <libnr/nr-matrix-ops.h>
7 #include <libnr/nr-point-matrix-ops.h>
8 #include <libnr/nr-translate.h>
9 #include <libnr/nr-translate-ops.h>
10 using NR::X;
11 using NR::Y;
13 class NrTranslateTest : public CxxTest::TestSuite
14 {
15 public:
17     NrTranslateTest() :
18         b( -2.0, 3.0 ),
19         tb( b ),
20         tc( -3.0, -2.0 ),
21         tbc( tb * tc ),
22         t_id( 0.0, 0.0 ),
23         m_id( NR::identity() )
24     {
25     }
26     virtual ~NrTranslateTest() {}
28 // createSuite and destroySuite get us per-suite setup and teardown
29 // without us having to worry about static initialization order, etc.
30     static NrTranslateTest *createSuite() { return new NrTranslateTest(); }
31     static void destroySuite( NrTranslateTest *suite ) { delete suite; }
33     NR::Point const b;
34     NR::translate const tb;
35     NR::translate const tc;
36     NR::translate const tbc;
37     NR::translate const t_id;
38     NR::Matrix const m_id;
41     void testCtorsArrayOperator(void)
42     {
43         TS_ASSERT_EQUALS( tc[X], -3.0 );
44         TS_ASSERT_EQUALS( tc[Y], -2.0 );
46         TS_ASSERT_EQUALS( tb[0], b[X] );
47         TS_ASSERT_EQUALS( tb[1], b[Y] );
48     }
50     void testAssignmentOperator(void)
51     {
52         NR::translate tb_eq(tc);
53         tb_eq = tb;
54         TS_ASSERT_EQUALS( tb, tb_eq );
55         TS_ASSERT_DIFFERS( tb_eq, tc );
56     }
58     void testOpStarTranslateTranslate(void)
59     {
60         TS_ASSERT_EQUALS( tbc.offset, NR::Point(-5.0, 1.0) );
61         TS_ASSERT_EQUALS( tbc.offset, ( tc * tb ).offset );
62         TS_ASSERT_EQUALS( NR::Matrix(tbc), NR::Matrix(tb) * NR::Matrix(tc) );
63     }
65     void testOpStarPointTranslate(void)
66     {
67         TS_ASSERT_EQUALS( tbc.offset, b * tc );
68         TS_ASSERT_EQUALS( b * tc, b * NR::Matrix(tc) );
69     }
71     void testIdentity(void)
72     {
73         TS_ASSERT_EQUALS( b * t_id, b );
74         TS_ASSERT_EQUALS( NR::Matrix(t_id), m_id );
75     }
76 };
78 /*
79   Local Variables:
80   mode:c++
81   c-file-style:"stroustrup"
82   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
83   indent-tabs-mode:nil
84   fill-column:99
85   End:
86 */
87 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :