1 /* This file is part of Metaproxy.
2 Copyright (C) 2005-2013 Index Data
4 Metaproxy is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
9 Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #include "html_parser.hpp"
24 #include <metaproxy/util.hpp>
26 #include <boost/lexical_cast.hpp>
30 #define BOOST_AUTO_TEST_MAIN
31 #define BOOST_TEST_DYN_LINK
33 #include <boost/test/auto_unit_test.hpp>
35 using namespace boost::unit_test;
36 namespace mp = metaproxy_1;
38 class MyEvent : public mp::HTMLParserEvent {
41 void openTagStart(const char *name)
47 void attribute(const char *tagName,
48 const char *name, const char *value, int val_len)
53 out.append(value, val_len);
57 void anyTagEnd(const char *name, int close_it)
64 void closeTag(const char *name)
70 void text(const char *value, int len)
72 out.append(value, len);
77 BOOST_AUTO_TEST_CASE( test_html_parser_1 )
83 "<html><body><a t1=v1 t2='v2' t3=\"v3\">some text</a>"
84 "<hr><table ></table ><a href=\"x\"/></body></html>";
85 const char* expected =
86 "<html><body><a t1=\"v1\" t2=\"v2\" t3=\"v3\">some text</a>"
87 "<hr><table></table><a href=\"x\"/></body></html>";
91 std::cout << expected << std::endl;
92 std::cout << e.out << std::endl;
93 BOOST_CHECK_EQUAL(std::string(expected), e.out);
95 catch (std::exception & e)
97 std::cout << e.what();
98 std::cout << std::endl;
107 * c-file-style: "Stroustrup"
108 * indent-tabs-mode: nil
110 * vim: shiftwidth=4 tabstop=8 expandtab