From 6dcfe679a15fd81aced28675b3ef91619165ae30 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 27 Jun 2013 11:50:04 +0200 Subject: [PATCH] More tests for html_parser --- src/test_html_parser.cpp | 68 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/src/test_html_parser.cpp b/src/test_html_parser.cpp index c4ffe13..5659152 100644 --- a/src/test_html_parser.cpp +++ b/src/test_html_parser.cpp @@ -80,6 +80,7 @@ BOOST_AUTO_TEST_CASE( test_html_parser_1 ) "some text" "
"; MyEvent e; + hp.set_verbose(1); hp.parse(e, html); std::cout << "Expected" << std::endl; @@ -116,6 +117,7 @@ BOOST_AUTO_TEST_CASE( test_html_parser_2 ) const char* expected = html; MyEvent e; + hp.set_verbose(1); hp.parse(e, html); std::cout << "Expected" << std::endl; @@ -133,6 +135,72 @@ BOOST_AUTO_TEST_CASE( test_html_parser_2 ) } } +BOOST_AUTO_TEST_CASE( test_html_parser_3 ) +{ + try + { + mp::HTMLParser hp; + const char* html = + "\n" + "\n" + " %local;\n" + "]>\n" + ""; + + const char* expected = html; + MyEvent e; + hp.set_verbose(1); + hp.parse(e, html); + + std::cout << "Expected" << std::endl; + std::cout << expected << std::endl; + std::cout << "Got" << std::endl; + std::cout << e.out << std::endl; + + BOOST_CHECK_EQUAL(std::string(expected), e.out); + } + catch (std::exception & e) + { + std::cout << e.what(); + std::cout << std::endl; + BOOST_CHECK (false); + } +} + +#if 0 +// null ptr exception +BOOST_AUTO_TEST_CASE( test_html_parser_4 ) +{ + try + { + mp::HTMLParser hp; + const char* html = + "<\"?xml version=\"1.0\" strandalone=\"no\"?>\n" + ""; + + const char* expected = html; + MyEvent e; + hp.set_verbose(1); + hp.parse(e, html); + + std::cout << "Expected" << std::endl; + std::cout << expected << std::endl; + std::cout << "Got" << std::endl; + std::cout << e.out << std::endl; + + BOOST_CHECK_EQUAL(std::string(expected), e.out); + } + catch (std::exception & e) + { + std::cout << e.what(); + std::cout << std::endl; + BOOST_CHECK (false); + } +} +#endif /* * Local variables: -- 1.7.10.4