started quick Taggle sense test

This commit is contained in:
jez 2009-03-09 21:29:32 +00:00
parent e26f2fc5f8
commit aba1deb76b
6 changed files with 113 additions and 2 deletions

View file

@ -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])

View file

@ -1,4 +1,4 @@
SUBDIRS = CppUnit Utils SAX
SUBDIRS = CppUnit Utils SAX Taggle
if WANT_DOM
SUBDIRS += DOM
endif

19
tests/Taggle/Makefile.am Executable file
View file

@ -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)

View file

@ -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 <Arabica/StringAdaptor.hpp>
#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

View file

@ -0,0 +1,56 @@
#ifndef ARABICA_TEST_TAGGLE_HPP
#define ARABICA_TEST_TAGGLE_HPP
#include <memory>
#include <sstream>
#include <iostream>
#include <SAX/filter/Writer.hpp>
#include <Taggle/Taggle.hpp>
#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<std::string> parser;
std::ostringstream sink;
Arabica::SAX::Writer<std::string> writer(sink, parser);
writer.parse(*source("<html><body>woo!<br></body></html>"));
assertEquals("<html>yay</html>", sink.str());
} // senseTest
private:
std::auto_ptr<Arabica::SAX::InputSource<std::string> > source(const std::string& str)
{
std::auto_ptr<std::iostream> ss(new std::stringstream());
(*ss) << str;
return std::auto_ptr<Arabica::SAX::InputSource<std::string> >(new Arabica::SAX::InputSource<std::string>(ss));
} // source
}; // TaggleTest
TestSuite* Taggle_test_suite()
{
TestSuite *suiteOfTests = new TestSuite;
suiteOfTests->addTest(new TestCaller<TaggleTest>("senseTest", &TaggleTest::senseTest));
return suiteOfTests;
} // TaggleTest_suite
#endif

View file

@ -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<URITest>("test40", &URITest::test40));
suiteOfTests->addTest(new TestCaller<URITest>("test41", &URITest::test41));
suiteOfTests->addTest(new TestCaller<URITest>("test42", &URITest::test42));
suiteOfTests->addTest(new TestCaller<URITest>("test43", &URITest::test43));
return suiteOfTests;
} // URITest_suite