diff options
| author | MenTaLguY <mental@rydia.net> | 2006-01-16 02:36:01 +0000 |
|---|---|---|
| committer | mental <mental@users.sourceforge.net> | 2006-01-16 02:36:01 +0000 |
| commit | 179fa413b047bede6e32109e2ce82437c5fb8d34 (patch) | |
| tree | a5a6ac2c1708bd02288fbd8edb2ff500ff2e0916 /src/svg/stringstream-test.h | |
| download | inkscape-179fa413b047bede6e32109e2ce82437c5fb8d34.tar.gz inkscape-179fa413b047bede6e32109e2ce82437c5fb8d34.zip | |
moving trunk for module inkscape
(bzr r1)
Diffstat (limited to 'src/svg/stringstream-test.h')
| -rw-r--r-- | src/svg/stringstream-test.h | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/src/svg/stringstream-test.h b/src/svg/stringstream-test.h new file mode 100644 index 000000000..6612f3fd2 --- /dev/null +++ b/src/svg/stringstream-test.h @@ -0,0 +1,70 @@ +#include <cxxtest/TestSuite.h> +#include "svg/stringstream.h" + +template<typename T> +static void +svg_test_datum(T const x, std::string const &exp_str) +{ + Inkscape::SVGOStringStream s; + s << x; + TS_ASSERT_EQUALS(s.str(), exp_str); +} + +static void +svg_test_float(float const x, std::string const &exp_str) +{ + svg_test_datum(x, exp_str); + svg_test_datum((double) x, exp_str); +} + +class StringStreamTest : public CxxTest::TestSuite +{ +public: + void testFloats() + { + svg_test_float(4.5, "4.5"); + svg_test_float(4.0, "4"); + svg_test_float(0.0, "0"); + svg_test_float(-3.75, "-3.75"); + svg_test_float(-2.0625, "-2.0625"); + svg_test_float(-0.0625, "-0.0625"); + svg_test_float(30.0, "30"); + svg_test_float(12345678.0, "12345678"); + svg_test_float(3e9, "3e+09"); + svg_test_float(-3.5e9, "-3.5e+09"); + svg_test_float(32768e9, "3.2768e+13"); + svg_test_float(-10.5, "-10.5"); + } + + void testOtherTypes() + { + svg_test_datum('3', "3"); + svg_test_datum('x', "x"); + svg_test_datum((unsigned char) '$', "$"); + svg_test_datum((signed char) 'Z', "Z"); + svg_test_datum(" my string ", " my string "); + svg_test_datum((signed char const *) "023", "023"); + svg_test_datum((unsigned char const *) "023", "023"); + } + + void testConcat() + { + Inkscape::SVGOStringStream s; + s << "hello, "; + s << -53.5; + TS_ASSERT_EQUALS(s.str(), std::string("hello, -53.5")); + } + +}; + + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : |
