Code

Filters. Custom predefined filters update and new ABC filters.
[inkscape.git] / src / svg / css-ostringstream-test.h
1 #include <cxxtest/TestSuite.h>
2 #include "svg/css-ostringstream.h"
4 template<typename T>
5 static void
6 css_test_datum(T const x, std::string const &exp_str)
7 {
8     Inkscape::CSSOStringStream s;
9     s << x;
10     TS_ASSERT_EQUALS(s.str(), exp_str);
11 }
13 static void
14 css_test_float(float const x, std::string const &exp_str)
15 {
16     css_test_datum(x, exp_str);
17     css_test_datum((double) x, exp_str);
18 }
20 class CSSOStringStreamTest : public CxxTest::TestSuite
21 {
22 public:
24 // createSuite and destroySuite get us per-suite setup and teardown
25 // without us having to worry about static initialization order, etc.
26     static CSSOStringStreamTest *createSuite() { return new CSSOStringStreamTest(); }
27     static void destroySuite( CSSOStringStreamTest *suite ) { delete suite; }
29     void testFloats()
30     {
31         css_test_float(4.5, "4.5");
32         css_test_float(4.0, "4");
33         css_test_float(0.0, "0");
34         css_test_float(-3.75, "-3.75");
35         css_test_float(-2.0625, "-2.0625");
36         css_test_float(-0.0625, "-0.0625");
37         css_test_float(30.0, "30");
38         css_test_float(12345678.0, "12345678");
39         css_test_float(3e9, "3000000000");
40         css_test_float(-3.5e9, "-3500000000");
41         css_test_float(3e-7, "0.0000003");
42         css_test_float(3e-8, "0.00000003");
43         css_test_float(3e-9, "0");
44         css_test_float(32768e9, "32768000000000");
45         css_test_float(-10.5, "-10.5");
46     }
48     void testOtherTypes()
49     {
50         css_test_datum('3', "3");
51         css_test_datum('x', "x");
52         css_test_datum((unsigned char) '$', "$");
53         css_test_datum((signed char) 'Z', "Z");
54         css_test_datum("  my string  ", "  my string  ");
55         css_test_datum((signed char const *) "023", "023");
56         css_test_datum((unsigned char const *) "023", "023");
57     }
59     void testConcat()
60     {
61         Inkscape::CSSOStringStream s;
62         s << "hello, ";
63         s << -53.5;
64         TS_ASSERT_EQUALS(s.str(), std::string("hello, -53.5"));
65     }
67 };
70 /*
71   Local Variables:
72   mode:c++
73   c-file-style:"stroustrup"
74   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
75   indent-tabs-mode:nil
76   fill-column:99
77   End:
78 */
79 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :