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)
57 void anyTagEnd(const char *name)
62 void closeTag(const char *name)
68 void text(const char *value, int len)
70 out.append(value, len);
75 BOOST_AUTO_TEST_CASE( test_html_parser_1 )
81 "<html><body><a t1=v1 t2='v2' t3=\"v3\">some text</a>"
82 "<hr><table ></table ></body></html";
83 const char* expected =
84 "<html><body><a t1=\"v1\" t2=\"v2\" t3=\"v3\">some text</a>"
85 "<hr><table></table></body></html";
88 BOOST_CHECK_EQUAL(std::string(expected), e.out);
90 catch (std::exception & e)
92 std::cout << e.what();
93 std::cout << std::endl;
102 * c-file-style: "Stroustrup"
103 * indent-tabs-mode: nil
105 * vim: shiftwidth=4 tabstop=8 expandtab