X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Ftest_html_parser.cpp;fp=src%2Ftest_html_parser.cpp;h=523011700b842079f2bdc31fbae5c07375e33226;hb=a258482a3b53b90b0932f4a789ba66e8e1576c05;hp=0000000000000000000000000000000000000000;hpb=100c5228470dc9e35d400d7ab641d5064d2079b1;p=metaproxy-moved-to-github.git diff --git a/src/test_html_parser.cpp b/src/test_html_parser.cpp new file mode 100644 index 0000000..5230117 --- /dev/null +++ b/src/test_html_parser.cpp @@ -0,0 +1,107 @@ +/* This file is part of Metaproxy. + Copyright (C) 2005-2013 Index Data + +Metaproxy is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 2, or (at your option) any later +version. + +Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "config.hpp" +#include +#include + +#include "html_parser.hpp" +#include + +#include + +#include + +#define BOOST_AUTO_TEST_MAIN +#define BOOST_TEST_DYN_LINK + +#include + +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 += "some text" + "
some text" + "