From cfe4f188e42817b168e7ebcf0f576f7082fe2734 Mon Sep 17 00:00:00 2001 From: joncruz Date: Fri, 28 Apr 2006 16:47:01 +0000 Subject: [PATCH] Replaced two tests with CxxTest versions. --- ChangeLog | 7 +++++ src/Makefile.am | 4 --- src/Makefile_insert | 8 ++---- src/dir-util-test.cpp | 48 ---------------------------------- src/dir-util-test.h | 48 ++++++++++++++++++++++++++++++++++ src/extract-uri-test.cpp | 56 ---------------------------------------- src/extract-uri-test.h | 49 +++++++++++++++++++++++++++++++++++ 7 files changed, 106 insertions(+), 114 deletions(-) delete mode 100644 src/dir-util-test.cpp create mode 100644 src/dir-util-test.h delete mode 100644 src/extract-uri-test.cpp create mode 100644 src/extract-uri-test.h diff --git a/ChangeLog b/ChangeLog index 30b8ddbf0..015854f39 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-04-28 Jon A. Cruz + + * src/Makefile_insert, src/Makefile.am, src/dir-util-test.h, + src/dir-util-test.cpp, src/extract-uri-test.h, + src/extract-uri-test.cpp: + Replaced two tests with CxxTest versions. + 2006-04-28 Jon A. Cruz * src/Makefile_insert, src/MultiPrinter.h, src/verbs.h, 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 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 - ("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 + +#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 -#include "extract-uri.h" -#include -#include - -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 + +#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 : -- 2.30.2