summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAndreas Baumann <abaumann@yahoo.com>2014-06-15 13:45:20 +0200
committerAndreas Baumann <abaumann@yahoo.com>2014-06-15 13:45:20 +0200
commit39ee887e91e0c7920193f7a519693b70f7de5a99 (patch)
tree6d77070e735ef8f04d4709e01ad25f1d64b14df1 /tests
parent967bf4c00d2342137fec917354f40241a9230c7a (diff)
downloadcrawler-39ee887e91e0c7920193f7a519693b70f7de5a99.tar.gz
crawler-39ee887e91e0c7920193f7a519693b70f7de5a99.tar.bz2
added error handling for textwolf tests
Diffstat (limited to 'tests')
-rw-r--r--tests/textwolf/GNUmakefile2
-rw-r--r--tests/textwolf/broken.xml28
-rw-r--r--tests/textwolf/test1.cpp5
-rw-r--r--tests/textwolf/test2.cpp4
4 files changed, 38 insertions, 1 deletions
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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
+ <sitemap>
+ <loc>http://relevancy.bger.ch/sitemaps/sitemap_atf_fr.xml</loc>
+ <lastmod>2014-06-14T10:10:03Z</lastmod>
+ </sitemap>
+ <sitemap>
+ <loc>http://relevancy.bger.ch/sitemaps/sitemap_cedh_fr.xml</loc>
+ <lastmod>2014-06-14T10:10:01Z</lastmod>
+ </sitemap>
+ <sitemap>
+ <loc>http://relevancy.bger.ch/sitemaps/sitemap_atf_it.xml</loc>
+ <lastmod>2014-06-14T10:10:04Z</lastmod>
+ </sitemap>
+ <sitemap>
+ <loc>http://relevancy.bger.ch/sitemaps/sitemap_cedh_it.xml</loc>
+ <lastmod>2014-06-14T10:10:01Z</lastmod>
+ </sitemap>
+ <sitemap>
+ <loc>http://relevancy.bger.ch/sitemaps/sitemap_cedh_de.xml</loc>
+ <lastmod>2014-06-14T10:10:01Z</lastmod>
+ </sitemap>
+ <sitemap>
+ <unterminated_tag>
+ <loc>http://relevancy.bger.ch/sitemaps/sitemap_atf_de.xml</loc>
+ <lastmod>2014-06-14T10:10:02Z</lastmod>
+ </sitemap>
+</sitemapindex>
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++ ) {