Code

Disable the page selector when there's only one page
[inkscape.git] / src / libnr / in-svg-plane-test.cpp
1 #include <glib/gmacros.h>
2 #include <cmath>
4 #include "libnr/in-svg-plane.h"
5 #include "utest/utest.h"
6 #include "isnan.h"
8 int main(int argc, char *argv[])
9 {
10     utest_start("in-svg-plane.h");
12     NR::Point const p3n4(3.0, -4.0);
13     NR::Point const p0(0.0, 0.0);
14     double const small = pow(2.0, -1070);
15     double const inf = 1e400;
16     double const nan = inf - inf;
18     NR::Point const small_left(-small, 0.0);
19     NR::Point const small_n3_4(-3.0 * small, 4.0 * small);
20     NR::Point const part_nan(3., nan);
22     assert(isNaN(nan));
23     assert(!isNaN(small));
25     UTEST_TEST("in_svg_plane") {
26         UTEST_ASSERT(in_svg_plane(p3n4));
27         UTEST_ASSERT(in_svg_plane(p0));
28         UTEST_ASSERT(in_svg_plane(small_left));
29         UTEST_ASSERT(in_svg_plane(small_n3_4));
30         UTEST_ASSERT(nan != nan);
31         UTEST_ASSERT(!in_svg_plane(NR::Point(nan, 3.)));
32         UTEST_ASSERT(!in_svg_plane(NR::Point(inf, nan)));
33         UTEST_ASSERT(!in_svg_plane(NR::Point(0., -inf)));
34         double const xs[] = {inf, -inf, nan, 1., -2., small, -small};
35         for (unsigned i = 0; i < G_N_ELEMENTS(xs); ++i) {
36             for (unsigned j = 0; j < G_N_ELEMENTS(xs); ++j) {
37                 UTEST_ASSERT( in_svg_plane(NR::Point(xs[i], xs[j]))
38                               == (fabs(xs[i]) < inf &&
39                                   fabs(xs[j]) < inf   ) );
40             }
41         }
42     }
44     return ( utest_end()
45              ? EXIT_SUCCESS
46              : EXIT_FAILURE );
47 }
49 /*
50   Local Variables:
51   mode:c++
52   c-file-style:"stroustrup"
53   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
54   indent-tabs-mode:nil
55   fill-column:99
56   End:
57 */
58 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :