X-Git-Url: http://sru.miketaylor.org.uk/?a=blobdiff_plain;f=src%2Ftest_html_parser.cpp;h=c4ffe131d947afc0e99fa3393035dad8691bba44;hb=3ef4df94516a136b7ee18ec8a45e740ef9e9dc05;hp=523011700b842079f2bdc31fbae5c07375e33226;hpb=a258482a3b53b90b0932f4a789ba66e8e1576c05;p=metaproxy-moved-to-github.git diff --git a/src/test_html_parser.cpp b/src/test_html_parser.cpp index 5230117..c4ffe13 100644 --- a/src/test_html_parser.cpp +++ b/src/test_html_parser.cpp @@ -35,40 +35,36 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA using namespace boost::unit_test; namespace mp = metaproxy_1; -class MyEvent : public mp::HTMLParserEvent { - public: - std::string out; - void openTagStart(const char *name) - { - out += "<"; - out += name; - } - - void attribute(const char *tagName, - const char *name, const char *value) - { - out += " "; - out += name; - out += "=\""; - out += value; - out += "\""; - } - - void anyTagEnd(const char *name) - { - out += ">"; - } - - void closeTag(const char *name) - { - out += ""; + } + void closeTag(const char *tag, int tag_len) { + out += "some text" - "
"; const char* expected = "some text" - "
"; MyEvent e; 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); + } +} + +BOOST_AUTO_TEST_CASE( test_html_parser_2 ) +{ + try + { + mp::HTMLParser hp; + const char* html = + "\n" + "\n" + " \n" + " YAZ 4.2.60\n" + " \n" + " \n" + "

YAZ 4.2.60

\n" + "

Error: 404

\n" + "

Description: Not Found

\n" + " \n" + ""; + + const char* expected = html; + MyEvent e; + 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)