1
#include <cxxtest/TestSuite.h>
3
#include <glib/gmacros.h>
6
#include "libnr/in-svg-plane.h"
7
#include "2geom/isnan.h"
9
class InSvgPlaneTest : public CxxTest::TestSuite
17
small( pow(2.0, -1070) ),
20
small_left( -small, 0.0 ),
21
small_n3_4( -3.0 * small, 4.0 * small ),
24
setupValid &= IS_NAN(nan);
25
setupValid &= !IS_NAN(small);
27
virtual ~InSvgPlaneTest() {}
29
// createSuite and destroySuite get us per-suite setup and teardown
30
// without us having to worry about static initialization order, etc.
31
static InSvgPlaneTest *createSuite() { return new InSvgPlaneTest(); }
32
static void destroySuite( InSvgPlaneTest *suite ) { delete suite; }
34
// Called before each test in this suite
37
TS_ASSERT( setupValid );
46
NR::Point const small_left;
47
NR::Point const small_n3_4;
48
NR::Point const part_nan;
51
void testInSvgPlane(void)
53
TS_ASSERT( in_svg_plane(p3n4) );
54
TS_ASSERT( in_svg_plane(p0) );
55
TS_ASSERT( in_svg_plane(small_left) );
56
TS_ASSERT( in_svg_plane(small_n3_4) );
57
TS_ASSERT_DIFFERS( nan, nan );
58
TS_ASSERT( !in_svg_plane(NR::Point(nan, 3.)) );
59
TS_ASSERT( !in_svg_plane(NR::Point(inf, nan)) );
60
TS_ASSERT( !in_svg_plane(NR::Point(0., -inf)) );
61
double const xs[] = {inf, -inf, nan, 1., -2., small, -small};
62
for (unsigned i = 0; i < G_N_ELEMENTS(xs); ++i) {
63
for (unsigned j = 0; j < G_N_ELEMENTS(xs); ++j) {
64
TS_ASSERT_EQUALS( in_svg_plane(NR::Point(xs[i], xs[j])),
66
fabs(xs[j]) < inf ) );
75
c-file-style:"stroustrup"
76
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
81
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :