From aba1deb76bd5ddd7c4157c5dc88b0cafef016e55 Mon Sep 17 00:00:00 2001 From: jez <> Date: Mon, 9 Mar 2009 21:29:32 +0000 Subject: [PATCH] started quick Taggle sense test --- configure.ac | 1 + tests/Makefile.am | 2 +- tests/Taggle/Makefile.am | 19 ++++++++++++ tests/Taggle/taggle_test.cpp | 22 ++++++++++++++ tests/Taggle/test_Taggle.hpp | 56 ++++++++++++++++++++++++++++++++++++ tests/Utils/test_uri.hpp | 15 +++++++++- 6 files changed, 113 insertions(+), 2 deletions(-) create mode 100755 tests/Taggle/Makefile.am create mode 100644 tests/Taggle/taggle_test.cpp create mode 100644 tests/Taggle/test_Taggle.hpp diff --git a/configure.ac b/configure.ac index 2c44da61..e8576e2b 100644 --- a/configure.ac +++ b/configure.ac @@ -37,6 +37,7 @@ AC_CONFIG_FILES([examples/XSLT/Makefile]) AC_CONFIG_FILES([tests/Makefile]) AC_CONFIG_FILES([tests/CppUnit/Makefile]) AC_CONFIG_FILES([tests/Utils/Makefile]) +AC_CONFIG_FILES([tests/Taggle/Makefile]) AC_CONFIG_FILES([tests/SAX/Makefile]) AC_CONFIG_FILES([tests/DOM/Makefile]) AC_CONFIG_FILES([tests/XPath/Makefile]) diff --git a/tests/Makefile.am b/tests/Makefile.am index b07c7a5f..58c64c0c 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = CppUnit Utils SAX +SUBDIRS = CppUnit Utils SAX Taggle if WANT_DOM SUBDIRS += DOM endif diff --git a/tests/Taggle/Makefile.am b/tests/Taggle/Makefile.am new file mode 100755 index 00000000..bd543ade --- /dev/null +++ b/tests/Taggle/Makefile.am @@ -0,0 +1,19 @@ + +check_PROGRAMS = taggle_test +if WANT_TESTS + TESTS = $(check_PROGRAMS) +endif + + +AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include @PARSER_HEADERS@ $(BOOST_CPPFLAGS) +LIBARABICA = $(top_builddir)/src/libarabica.la +TESTLIBS = $(LIBARABICA) ../CppUnit/libcppunit.la + +test_sources = test_WhitespaceStripper.hpp + +taggle_test_SOURCES = taggle_test.cpp \ + $(test_sources) +taggle_test_LDADD = $(TESTLIBS) +taggle_test_DEPENDENCIES = $(TESTLIBS) + + diff --git a/tests/Taggle/taggle_test.cpp b/tests/Taggle/taggle_test.cpp new file mode 100644 index 00000000..5b926045 --- /dev/null +++ b/tests/Taggle/taggle_test.cpp @@ -0,0 +1,22 @@ +#ifdef _MSC_VER +#pragma warning(disable: 4786 4250 4503) +#endif + +#include "../CppUnit/TestRunner.hpp" +#include "../CppUnit/framework/Test.h" +#include "../CppUnit/framework/TestSuite.h" +#include +#include "test_Taggle.hpp" + +//////////////////////////////////////////////// +int main(int argc, const char* argv[]) +{ + TestRunner runner; + + runner.addTest("TaggleTest", Taggle_test_suite()); + + bool ok = runner.run(argc, argv); + + return !ok; +} // main + diff --git a/tests/Taggle/test_Taggle.hpp b/tests/Taggle/test_Taggle.hpp new file mode 100644 index 00000000..dd46172c --- /dev/null +++ b/tests/Taggle/test_Taggle.hpp @@ -0,0 +1,56 @@ +#ifndef ARABICA_TEST_TAGGLE_HPP +#define ARABICA_TEST_TAGGLE_HPP + +#include +#include +#include + +#include +#include + +#include "../CppUnit/framework/TestCase.h" +#include "../CppUnit/framework/TestSuite.h" +#include "../CppUnit/framework/TestCaller.h" + +class TaggleTest : public TestCase +{ + public: + TaggleTest(std::string name) : + TestCase(name) + { + } // TaggleTest + + void setUp() + { + } // setUp + + void senseTest() + { + Arabica::SAX::Taggle parser; + std::ostringstream sink; + Arabica::SAX::Writer writer(sink, parser); + + writer.parse(*source("woo!
")); + assertEquals("yay", sink.str()); + } // senseTest + + private: + std::auto_ptr > source(const std::string& str) + { + std::auto_ptr ss(new std::stringstream()); + (*ss) << str; + return std::auto_ptr >(new Arabica::SAX::InputSource(ss)); + } // source +}; // TaggleTest + +TestSuite* Taggle_test_suite() +{ + TestSuite *suiteOfTests = new TestSuite; + + suiteOfTests->addTest(new TestCaller("senseTest", &TaggleTest::senseTest)); + + return suiteOfTests; +} // TaggleTest_suite + +#endif + diff --git a/tests/Utils/test_uri.hpp b/tests/Utils/test_uri.hpp index 8e22be6c..47f12a38 100644 --- a/tests/Utils/test_uri.hpp +++ b/tests/Utils/test_uri.hpp @@ -478,12 +478,24 @@ class URITest : public TestCase URI b("wooo/main.txt"); URI u(b, "file:fragtastic/woot.txt"); + assertEquals("", u.host()); + assertEquals("", u.scheme()); + assertEquals("wooo/fragtastic/woot.txt", u.path()); + assertEquals(false, u.is_absolute()); + assertEquals("wooo/fragtastic/woot.txt", u.as_string()); + } // test42 + + void test43() + { + URI b("file:wooo/main.txt"); + URI u(b, "file:fragtastic/woot.txt"); + assertEquals("", u.host()); assertEquals("file", u.scheme()); assertEquals("wooo/fragtastic/woot.txt", u.path()); assertEquals(false, u.is_absolute()); assertEquals("file:wooo/fragtastic/woot.txt", u.as_string()); - } // test42 + } // test43 }; // class URITest TestSuite* URITest_suite() @@ -532,6 +544,7 @@ TestSuite* URITest_suite() suiteOfTests->addTest(new TestCaller("test40", &URITest::test40)); suiteOfTests->addTest(new TestCaller("test41", &URITest::test41)); suiteOfTests->addTest(new TestCaller("test42", &URITest::test42)); + suiteOfTests->addTest(new TestCaller("test43", &URITest::test43)); return suiteOfTests; } // URITest_suite