From 39ee887e91e0c7920193f7a519693b70f7de5a99 Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Sun, 15 Jun 2014 13:45:20 +0200 Subject: added error handling for textwolf tests --- tests/textwolf/GNUmakefile | 2 ++ tests/textwolf/broken.xml | 28 ++++++++++++++++++++++++++++ tests/textwolf/test1.cpp | 5 ++++- tests/textwolf/test2.cpp | 4 ++++ 4 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 tests/textwolf/broken.xml (limited to 'tests') diff --git a/tests/textwolf/GNUmakefile b/tests/textwolf/GNUmakefile index 3324619..885d322 100644 --- a/tests/textwolf/GNUmakefile +++ b/tests/textwolf/GNUmakefile @@ -26,3 +26,5 @@ local_distclean: local_test: @./test1 test.xml @./test2 test.xml + @./test1 broken.xml + @./test2 broken.xml diff --git a/tests/textwolf/broken.xml b/tests/textwolf/broken.xml new file mode 100644 index 0000000..6fb5c7a --- /dev/null +++ b/tests/textwolf/broken.xml @@ -0,0 +1,28 @@ + + + + http://relevancy.bger.ch/sitemaps/sitemap_atf_fr.xml + 2014-06-14T10:10:03Z + + + http://relevancy.bger.ch/sitemaps/sitemap_cedh_fr.xml + 2014-06-14T10:10:01Z + + + http://relevancy.bger.ch/sitemaps/sitemap_atf_it.xml + 2014-06-14T10:10:04Z + + + http://relevancy.bger.ch/sitemaps/sitemap_cedh_it.xml + 2014-06-14T10:10:01Z + + + http://relevancy.bger.ch/sitemaps/sitemap_cedh_de.xml + 2014-06-14T10:10:01Z + + + + http://relevancy.bger.ch/sitemaps/sitemap_atf_de.xml + 2014-06-14T10:10:02Z + + diff --git a/tests/textwolf/test1.cpp b/tests/textwolf/test1.cpp index ea0b985..426f931 100644 --- a/tests/textwolf/test1.cpp +++ b/tests/textwolf/test1.cpp @@ -42,9 +42,11 @@ int main( int argc, char *argv[] ) case Scanner::CloseTag: currentTag.clear( ); break; + + case Scanner::ErrorOccurred: + throw runtime_error( itr->content( ) ); case Scanner::None: - case Scanner::ErrorOccurred: case Scanner::HeaderStart: case Scanner::HeaderAttribName: case Scanner::HeaderAttribValue: @@ -55,6 +57,7 @@ int main( int argc, char *argv[] ) case Scanner::TagAttribValue: case Scanner::CloseTagIm: case Scanner::Exit: + default: break; } diff --git a/tests/textwolf/test2.cpp b/tests/textwolf/test2.cpp index 79d1a6d..f121995 100644 --- a/tests/textwolf/test2.cpp +++ b/tests/textwolf/test2.cpp @@ -39,6 +39,10 @@ int main( int argc, char *argv[] ) Scanner::iterator ci, ce; for( ci = xsc.begin( ), ce = xsc.end( ); ci != ce; ci++ ) { + if( ci->type( ) == Scanner::ErrorOccurred ) { + throw std::runtime_error( ci->content( ) ); + } + PathSelect::iterator itr = xsel.push( ci->type( ), ci->content( ), ci->size( ) ); PathSelect::iterator end = xsel.end( ); for( ; itr != end; itr++ ) { -- cgit v1.2.3-54-g00ecf