summaryrefslogtreecommitdiffstats
path: root/src/helper
diff options
context:
space:
mode:
authorKrzysztof Kosi??ski <tweenk.pl@gmail.com>2008-12-09 00:06:13 +0000
committertweenk <tweenk@users.sourceforge.net>2008-12-09 00:06:13 +0000
commited0c006e81c69fbed16181c512c55190d998892e (patch)
tree37e6c6d558eceb3e7b4ac9f5ac3aaac41b854863 /src/helper
parentfix for Bug #234305 (paste into transformed groups) (diff)
downloadinkscape-ed0c006e81c69fbed16181c512c55190d998892e.tar.gz
inkscape-ed0c006e81c69fbed16181c512c55190d998892e.zip
Simplify "make check" makefile rules and remove most of the obsolete
utest-based tests. (bzr r6976)
Diffstat (limited to 'src/helper')
-rw-r--r--src/helper/Makefile_insert32
-rw-r--r--src/helper/units-test.cpp115
2 files changed, 11 insertions, 136 deletions
diff --git a/src/helper/Makefile_insert b/src/helper/Makefile_insert
index bf8128110..73cc3d5ee 100644
--- a/src/helper/Makefile_insert
+++ b/src/helper/Makefile_insert
@@ -40,7 +40,7 @@ helper_libspchelp_a_SOURCES = \
helper/stock-items.cpp \
helper/stock-items.h
-# cmp exits with status 0 when there are no differences. if executes the commands
+# cmp exits with status 0 when there are no differences. "if" executes the commands
# after "then" when the exit status of the if command is 0 (this is crazy).
helper/sp-marshal.h: helper/sp-marshal.list
glib-genmarshal --prefix=sp_marshal --header $(srcdir)/helper/sp-marshal.list > helper/tmp.sp-marshal.h
@@ -58,29 +58,19 @@ helper/sp-marshal.cpp: helper/sp-marshal.list helper/sp-marshal.h
helper/sp-marshal.cpp helper/sp-marshal.h: helper/sp-marshal.list
-helper_units_test_SOURCES = helper/units-test.cpp
-helper_units_test_LDADD = helper/libspchelp.a -lglib-2.0
-
-# Copy/paste from libnr
-helper/test-helper-main.cpp: helper/test-helper.cpp
- $(top_srcdir)/cxxtest/cxxtestgen.pl --template=$(srcdir)/selfname.tpl -root -o helper/test-helper-main.cpp $(helper_test_helper_includes)
-
-helper/test-helper.cpp: $(helper_test_helper_includes)
- $(top_srcdir)/cxxtest/cxxtestgen.pl --have-eh -part -o helper/test-helper.cpp $(helper_test_helper_includes)
-
-helper_test_helper_includes = \
+# ######################
+# ### CxxTest stuff ####
+# ######################
+helper_testsuites = \
$(srcdir)/helper/units-test.h
-helper_libtest_helper_a_SOURCES = \
- helper/test-helper.cpp \
- $(helper_test_helper_includes)
-
helper_test_helper_SOURCES = \
- helper/test-helper-main.cpp \
- $(helper_test_helper_includes)
+ helper/test-helper.cpp \
+ $(helper_testsuites)
-helper_test_helper_LDADD = \
- helper/libspchelp.a \
- helper/libtest-helper.a \
+helper_test_helper_LDADD = \
+ helper/libspchelp.a \
-lglib-2.0
+helper/test-helper.cpp: $(helper_testsuites) helper/Makefile_insert $(CXXTEST_TEMPLATE)
+ $(CXXTESTGEN) -o xml/test-xml.cpp $(helper_testsuites)
diff --git a/src/helper/units-test.cpp b/src/helper/units-test.cpp
deleted file mode 100644
index a400ca01f..000000000
--- a/src/helper/units-test.cpp
+++ /dev/null
@@ -1,115 +0,0 @@
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-#include <math.h>
-
-#include <glibmm/i18n.h>
-#include <helper/units.h>
-#include <utest/utest.h>
-
-
-/* N.B. Wrongly returns false if both near 0. (Not a problem for current users.) */
-static bool
-approx_equal(double const x, double const y)
-{
- return fabs(x / y - 1) < 1e-15;
-}
-
-static double
-sp_units_get_points(double const x, SPUnit const &unit)
-{
- SPUnit const &pt_unit = sp_unit_get_by_id(SP_UNIT_PT);
- double const px = sp_units_get_pixels(x, unit);
- return sp_pixels_get_units(px, pt_unit);
-}
-
-static double
-sp_points_get_units(double const pts, SPUnit const &unit)
-{
- SPUnit const &pt_unit = sp_unit_get_by_id(SP_UNIT_PT);
- double const px = sp_units_get_pixels(pts, pt_unit);
- return sp_pixels_get_units(px, unit);
-}
-
-static bool
-test_conversions()
-{
- utest_start("sp_units_get_pixels, sp_pixels_get_units");
-
- struct Case { double x; char const *abbr; double pts; } const tests[] = {
- { 1.0, "pt", 1.0 },
- { 5.0, "pt", 5.0 },
- { 1.0, "in", 72.0 },
- { 2.0, "in", 144.0 },
- { 254., "mm", 720.0 },
- { 254., "cm", 7200. },
- { 254., "m", 720000. },
- { 1.5, "mm", (15 * 72. / 254) }
- };
- for (unsigned i = 0; i < G_N_ELEMENTS(tests); ++i) {
- char name[80];
- Case const &c = tests[i];
- SPUnit const &unit = *sp_unit_get_by_abbreviation(N_(c.abbr));
-
- double const calc_pts = sp_units_get_points(c.x, unit);
- snprintf(name, sizeof(name), "%.1f %s -> %.1f pt", c.x, c.abbr, c.pts);
- UTEST_TEST(name) {
- UTEST_ASSERT(approx_equal(calc_pts, c.pts));
- }
-
- double const calc_x = sp_points_get_units(c.pts, unit);
- snprintf(name, sizeof(name), "%.1f pt -> %.1f %s", c.pts, c.x, c.abbr);
- UTEST_TEST(name) {
- UTEST_ASSERT(approx_equal(calc_x, c.x));
- }
-
- double tmp = c.x;
- bool const converted_to_pts = sp_convert_distance(&tmp, &unit, SP_PS_UNIT);
- snprintf(name, sizeof(name), "convert %.1f %s -> %.1f pt", c.x, c.abbr, c.pts);
- UTEST_TEST(name) {
- UTEST_ASSERT(converted_to_pts);
- UTEST_ASSERT(approx_equal(tmp, c.pts));
- }
-
- tmp = c.pts;
- bool const converted_from_pts = sp_convert_distance(&tmp, SP_PS_UNIT, &unit);
- snprintf(name, sizeof(name), "convert %.1f pt -> %.1f %s", c.pts, c.x, c.abbr);
- UTEST_TEST(name) {
- UTEST_ASSERT(converted_from_pts);
- UTEST_ASSERT(approx_equal(tmp, c.x));
- }
- }
- return utest_end();
-}
-
-static bool
-test_unit_table()
-{
- utest_start("unit table");
- UTEST_TEST("sp_units_table_sane") {
- UTEST_ASSERT(sp_units_table_sane());
- }
- return utest_end();
-}
-
-int
-main(int /*argc*/, char */*argv*/[])
-{
- int const ret = ( ( test_conversions()
- && test_unit_table() )
- ? EXIT_SUCCESS
- : EXIT_FAILURE );
- return ret;
-}
-
-
-/*
- 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 :