1
#include <cxxtest/TestSuite.h>
3
#include <libnr/scale.h>
4
#include <libnr/scale-ops.h>
8
class NrScaleTest : public CxxTest::TestSuite
18
virtual ~NrScaleTest() {}
20
// createSuite and destroySuite get us per-suite setup and teardown
21
// without us having to worry about static initialization order, etc.
22
static NrScaleTest *createSuite() { return new NrScaleTest(); }
23
static void destroySuite( NrScaleTest *suite ) { delete suite; }
31
void testXY_CtorArrayOperator(void)
33
TS_ASSERT_EQUALS( sa[X], 1.5 );
34
TS_ASSERT_EQUALS( sa[Y], 2.0 );
35
TS_ASSERT_EQUALS( sa[0u], 1.5 );
36
TS_ASSERT_EQUALS( sa[1u], 2.0 );
40
void testCopyCtor_AssignmentOp_NotEquals(void)
42
Geom::scale const sa_copy(sa);
43
TS_ASSERT_EQUALS( sa, sa_copy );
44
TS_ASSERT(!( sa != sa_copy ));
45
TS_ASSERT( sa != sb );
48
void testAssignmentOp(void)
50
Geom::scale sa_eq(sb);
52
TS_ASSERT_EQUALS( sa, sa_eq );
55
void testPointCtor(void)
57
TS_ASSERT_EQUALS( sb[X], b[X] );
58
TS_ASSERT_EQUALS( sb[Y], b[Y] );
61
void testOpStarPointScale(void)
63
Geom::Point const ab( b * sa );
64
TS_ASSERT_EQUALS( ab, Geom::Point(-3.0, 6.0) );
67
void testOpStarScaleScale(void)
69
Geom::scale const sab( sa * sb );
70
TS_ASSERT_EQUALS( sab, Geom::scale(-3.0, 6.0) );
73
void testOpDivScaleScale(void)
75
Geom::scale const sa_b( sa / sb );
76
Geom::scale const exp_sa_b(-0.75, 2./3.);
77
TS_ASSERT_EQUALS( sa_b[0], exp_sa_b[0] );
78
// TS_ASSERT_EQUALS( fabs( sa_b[1] - exp_sa_b[1] ) < 1e-10 );
79
TS_ASSERT_DELTA( sa_b[1], exp_sa_b[1], 1e-10 );
86
c-file-style:"stroustrup"
87
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
92
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :