7 #define BOOST_TEST_DYN_LINK
8 #define BOOST_TEST_MODULE "Test module for rapidxml"
13 #include <boost/test/unit_test.hpp>
14 #include <boost/algorithm/string.hpp>
16 #include "rapidxml/rapidxml.hpp"
19 using namespace boost;
26 std::cout <<
"Node \'" << node->name() <<
"\'";
27 std::cout <<
" w value [" << node->value() <<
"]\n";
29 for (xml_attribute<> *attr = node->first_attribute(); attr ; attr = attr->next_attribute())
31 std::cout <<
" + attribute \'" << attr->name() <<
"\'' ";
32 std::cout <<
"with value [" << attr->value() <<
"]\n";
35 for (
xml_node<> * itr = node->first_node(); itr ; itr = itr->next_sibling() )
45 rapidxml::memory_pool<>& mem = *out.document();
47 char* nname = mem.allocate_string(in.name());
48 char* nvalue = mem.allocate_string(in.value());
58 rapidxml::xml_attribute<>* iattr = in.first_attribute();
59 rapidxml::xml_attribute<>* oattr = out.first_attribute();
61 for ( ; iattr ; iattr = iattr->next_attribute(),
62 oattr = oattr->next_attribute() )
64 char* aname = mem.allocate_string(iattr->name());
65 char* avalue = mem.allocate_string(iattr->value());
79 for ( ; inode ; inode = inode->next_sibling(),
80 onode = onode->next_sibling() )
89 rapidxml::memory_pool<>& mem = *out.document();
90 mem.clone_node(&in,&out);
115 std::string text = (
"<debug lolo=\"1\" koko=\"2\" >"
117 "<filename>debug.log</filename>"
118 "<modules NBS=\"3\">"
119 " <module>Finance</module>"
120 " <module>Admin</module>"
121 " <module>HR</module>"
130 char* ctext = doc.allocate_string(text.c_str());
132 doc.parse< rapidxml::parse_no_data_nodes |
133 rapidxml::parse_trim_whitespace |
134 parse_normalize_whitespace > (ctext);
147 BOOST_AUTO_TEST_SUITE_END()
149 RapidXML_Test_Fixture()
common setup for each test case
external boost library namespace
void deep_copy(rapidxml::xml_node<> &in, rapidxml::xml_node<> &out)
deep copies a node into another with all the memory allocated in the second
void print_xml_node(rapidxml::xml_node<> *node)
prints the xml node to screen
BOOST_AUTO_TEST_CASE(parsing)
~RapidXML_Test_Fixture()
common tear-down for each test case
void deep_copy_names_values(rapidxml::xml_node<> &in, rapidxml::xml_node<> &out)
external library used for XML parsing