summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJon A. Cruz <jon@joncruz.org>2006-04-28 16:47:01 +0000
committerjoncruz <joncruz@users.sourceforge.net>2006-04-28 16:47:01 +0000
commit018fe5a60c309a2eebd42c3385401d1dc6ba8435 (patch)
tree0e662200eaf1a5b33426927338f315ed8a0ca55f /src
parentAdding unit test for verbs. (diff)
downloadinkscape-018fe5a60c309a2eebd42c3385401d1dc6ba8435.tar.gz
inkscape-018fe5a60c309a2eebd42c3385401d1dc6ba8435.zip
Replaced two tests with CxxTest versions.
(bzr r605)
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am4
-rw-r--r--src/Makefile_insert8
-rw-r--r--src/dir-util-test.cpp48
-rw-r--r--src/dir-util-test.h48
-rw-r--r--src/extract-uri-test.cpp56
-rw-r--r--src/extract-uri-test.h49
6 files changed, 99 insertions, 114 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index b4fd7a563..1f6bcefab 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -166,8 +166,6 @@ EXTRA_PROGRAMS = \
TESTS = \
test-all$(EXEEXT) \
- dir-util-test$(EXEEXT) \
- extract-uri-test$(EXEEXT) \
mod360-test$(EXEEXT) \
round-test$(EXEEXT) \
sp-gradient-test$(EXEEXT) \
@@ -200,8 +198,6 @@ TESTS = \
check_PROGRAMS = \
test-all \
- dir-util-test \
- extract-uri-test \
mod360-test \
round-test \
sp-gradient-test \
diff --git a/src/Makefile_insert b/src/Makefile_insert
index a797984e9..00c3be726 100644
--- a/src/Makefile_insert
+++ b/src/Makefile_insert
@@ -319,15 +319,9 @@ inkscape_LDFLAGS = --export-dynamic $(kdeldflags)
inkview_SOURCES = inkview.cpp $(win32_sources)
inkview_LDADD = $(all_libs)
-dir_util_test_SOURCES = dir-util-test.cpp utest/test-2ary-cases.h
-dir_util_test_LDADD = dir-util.$(OBJEXT) -lglib-2.0
-
mod360_test_SOURCES = mod360-test.cpp
mod360_test_LDADD = libinkpre.a -lglib-2.0
-extract_uri_test_SOURCES = extract-uri-test.cpp
-extract_uri_test_LDADD = libinkpre.a -lglib-2.0
-
round_test_SOURCES = round-test.cpp
round_test_LDADD = libinkpost.a
@@ -346,4 +340,6 @@ inkscape_version.h: ../configure.ac
test_all_includes = \
attributes-test.h \
color-profile-test.h \
+ dir-util-test.h \
+ extract-uri-test.h \
verbs-test.h
diff --git a/src/dir-util-test.cpp b/src/dir-util-test.cpp
deleted file mode 100644
index 691f6fee1..000000000
--- a/src/dir-util-test.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-#include "utest/test-2ary-cases.h"
-#include "dir-util.h"
-#include "streq.h"
-
-struct streq_functor {
- bool operator()(char const *a, char const *b)
- {
- return streq(a, b);
- }
-};
-
-static bool
-test_sp_relative_path_from_path()
-{
- utest_start("sp_relative_path_from_path");
- struct Case2<char const *, char const *, char const *> cases[] = {
- {"/foo/bar", "/foo", "bar"},
- {"/foo/barney", "/foo/bar", "/foo/barney"},
- {"/foo/bar/baz", "/foo/", "bar/baz"},
- {"/foo/bar/baz", "/", "foo/bar/baz"},
- {"/foo/bar/baz", "/foo/qux", "/foo/bar/baz"},
- {"/foo", NULL, "/foo"}
- };
- test_2ary_cases<char const *, char const *, char const *, char const *, streq_functor>
- ("sp_relative_path_from_path",
- sp_relative_path_from_path,
- G_N_ELEMENTS(cases), cases);
- return utest_end();
-}
-
-int main()
-{
- return ( test_sp_relative_path_from_path()
- ? EXIT_SUCCESS
- : EXIT_FAILURE );
-}
-
-
-/*
- 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 :
diff --git a/src/dir-util-test.h b/src/dir-util-test.h
new file mode 100644
index 000000000..e2f0f8ed8
--- /dev/null
+++ b/src/dir-util-test.h
@@ -0,0 +1,48 @@
+
+#ifndef SEEN_DIR_UTIL_TEST_H
+#define SEEN_DIR_UTIL_TEST_H
+
+#include <cxxtest/TestSuite.h>
+
+#include "dir-util.h"
+
+class DirUtilTest : public CxxTest::TestSuite
+{
+public:
+ void testBase()
+ {
+ char const* cases[][3] = {
+ {"/foo/bar", "/foo", "bar"},
+ {"/foo/barney", "/foo/bar", "/foo/barney"},
+ {"/foo/bar/baz", "/foo/", "bar/baz"},
+ {"/foo/bar/baz", "/", "foo/bar/baz"},
+ {"/foo/bar/baz", "/foo/qux", "/foo/bar/baz"},
+ {"/foo", NULL, "/foo"}
+ };
+
+ for ( size_t i = 0; i < G_N_ELEMENTS(cases); i++ )
+ {
+ char const* result = sp_relative_path_from_path( cases[i][0], cases[i][1] );
+ TS_ASSERT( result );
+ TS_ASSERT( cases[i][2] );
+ if ( result && cases[i][2] )
+ {
+ TS_ASSERT_EQUALS( std::string(result), std::string(cases[i][2]) );
+ }
+ }
+ }
+
+};
+
+#endif // SEEN_DIR_UTIL_TEST_H
+
+/*
+ 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 :
diff --git a/src/extract-uri-test.cpp b/src/extract-uri-test.cpp
deleted file mode 100644
index 9bf44baca..000000000
--- a/src/extract-uri-test.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-#include <utest/utest.h>
-#include "extract-uri.h"
-#include <string.h>
-#include <glib.h>
-
-struct Case {
- char const *input;
- char const *exp;
-};
-
-static void test_extract_uri_case(Case const &c)
-{
- char * const p = extract_uri(c.input);
- UTEST_TEST(c.input) {
- UTEST_ASSERT( ( p == NULL ) == ( c.exp == NULL ) );
- if (p) {
- UTEST_ASSERT( strcmp(p, c.exp) == 0 );
- }
- }
- g_free(p);
-}
-
-int main(int argc, char *argv[])
-{
- utest_start("extract_uri");
-
- Case const cases[] = {
- { "url(#foo)", "#foo" },
- { "url foo ", "foo" },
- { "url", NULL },
- { "url ", NULL },
- { "url()", NULL },
- { "url ( ) ", NULL },
- { "url foo bar ", "foo bar" }
- };
-
- for(unsigned i = 0; i < G_N_ELEMENTS(cases); ++i) {
- Case const &c = cases[i];
- test_extract_uri_case(c);
- }
-
- return ( utest_end()
- ? EXIT_SUCCESS
- : EXIT_FAILURE );
-}
-
-/*
- 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 :
diff --git a/src/extract-uri-test.h b/src/extract-uri-test.h
new file mode 100644
index 000000000..d50628621
--- /dev/null
+++ b/src/extract-uri-test.h
@@ -0,0 +1,49 @@
+
+#ifndef SEEN_EXTRACT_URI_TEST_H
+#define SEEN_EXTRACT_URI_TEST_H
+
+#include <cxxtest/TestSuite.h>
+
+#include "extract-uri.h"
+
+class ExtractURITest : public CxxTest::TestSuite
+{
+public:
+ void testBase()
+ {
+ char const* cases[][2] = {
+ { "url(#foo)", "#foo" },
+ { "url foo ", "foo" },
+ { "url", NULL },
+ { "url ", NULL },
+ { "url()", NULL },
+ { "url ( ) ", NULL },
+ { "url foo bar ", "foo bar" }
+ };
+
+ for ( size_t i = 0; i < G_N_ELEMENTS(cases); i++ )
+ {
+ char const* result = extract_uri( cases[i][0] );
+
+ TS_ASSERT_EQUALS( ( result == NULL ), ( cases[i][1] == NULL ) );
+ if ( result )
+ {
+ TS_ASSERT_EQUALS( std::string(result), std::string(cases[i][1]) );
+ }
+ }
+ }
+
+};
+
+#endif // SEEN_EXTRACT_URI_TEST_H
+
+/*
+ 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 :