|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r59161 - in trunk: boost/property_tree/detail libs/property_tree/test
From: sebastian.redl_at_[hidden]
Date: 2010-01-20 13:47:51
Author: cornedbee
Date: 2010-01-20 13:47:50 EST (Wed, 20 Jan 2010)
New Revision: 59161
URL: http://svn.boost.org/trac/boost/changeset/59161
Log:
Fix a weakness in the XML whitespace tests. This allows me to have correct tests after fixing PR2855, which is also in this commit.
Text files modified:
trunk/boost/property_tree/detail/rapidxml.hpp | 3 ++-
trunk/boost/property_tree/detail/xml_parser_write.hpp | 16 +++++++++++-----
trunk/libs/property_tree/test/test_xml_parser_common.hpp | 17 ++++++++++++-----
trunk/libs/property_tree/test/test_xml_parser_rapidxml.cpp | 3 ++-
trunk/libs/property_tree/test/xml_parser_test_data.hpp | 4 ++++
5 files changed, 31 insertions(+), 12 deletions(-)
Modified: trunk/boost/property_tree/detail/rapidxml.hpp
==============================================================================
--- trunk/boost/property_tree/detail/rapidxml.hpp (original)
+++ trunk/boost/property_tree/detail/rapidxml.hpp 2010-01-20 13:47:50 EST (Wed, 20 Jan 2010)
@@ -2177,7 +2177,8 @@
{
// Skip whitespace between > and node contents
Ch *contents_start = text; // Store start of node contents before whitespace is skipped
- skip<whitespace_pred, Flags>(text);
+ if (Flags & parse_trim_whitespace)
+ skip<whitespace_pred, Flags>(text);
Ch next_char = *text;
// After data nodes, instead of continuing the loop, control jumps here.
Modified: trunk/boost/property_tree/detail/xml_parser_write.hpp
==============================================================================
--- trunk/boost/property_tree/detail/xml_parser_write.hpp (original)
+++ trunk/boost/property_tree/detail/xml_parser_write.hpp 2010-01-20 13:47:50 EST (Wed, 20 Jan 2010)
@@ -31,14 +31,18 @@
void write_xml_comment(std::basic_ostream<Ch> &stream,
const std::basic_string<Ch> &s,
int indent,
+ bool separate_line,
const xml_writer_settings<Ch> & settings
)
{
typedef typename std::basic_string<Ch> Str;
- write_xml_indent(stream,indent,settings);
+ if (separate_line)
+ write_xml_indent(stream,indent,settings);
stream << Ch('<') << Ch('!') << Ch('-') << Ch('-');
stream << s;
- stream << Ch('-') << Ch('-') << Ch('>') << std::endl;
+ stream << Ch('-') << Ch('-') << Ch('>');
+ if (separate_line)
+ stream << Ch('\n');
}
template<class Ch>
@@ -52,7 +56,7 @@
if (separate_line)
write_xml_indent(stream,indent,settings);
stream << encode_char_entities(s);
- if (separate_line)
+ if (separate_line)
stream << Ch('\n');
}
@@ -92,7 +96,9 @@
{
write_xml_indent(stream,indent,settings);
stream << Ch('<') << key <<
- Ch('/') << Ch('>') << std::endl;
+ Ch('/') << Ch('>');
+ if (want_pretty)
+ stream << Ch('\n');
}
}
else // Nonempty key
@@ -144,7 +150,7 @@
else if (it->first == xmlcomment<Ch>())
write_xml_comment(stream,
it->second.template get_value<std::basic_string<Ch> >(),
- indent + 1, settings);
+ indent + 1, want_pretty, settings);
else if (it->first == xmltext<Ch>())
write_xml_text(stream,
it->second.template get_value<std::basic_string<Ch> >(),
Modified: trunk/libs/property_tree/test/test_xml_parser_common.hpp
==============================================================================
--- trunk/libs/property_tree/test/test_xml_parser_common.hpp (original)
+++ trunk/libs/property_tree/test/test_xml_parser_common.hpp 2010-01-20 13:47:50 EST (Wed, 20 Jan 2010)
@@ -19,7 +19,8 @@
template<class Ptree>
void operator()(const std::string &filename, Ptree &pt) const
{
- boost::property_tree::read_xml(filename, pt);
+ boost::property_tree::read_xml(filename, pt,
+ boost::property_tree::xml_parser::no_concat_text);
}
};
@@ -72,7 +73,7 @@
generic_parser_test_ok<Ptree, ReadFuncWS, WriteFuncWS>
(
ReadFuncWS(), WriteFuncWS(), ok_data_2, NULL,
- "testok2a.xml", NULL, "testok2aout.xml", 6, 18, 8
+ "testok2a.xml", NULL, "testok2aout.xml", 15, 23, 89
);
generic_parser_test_ok<Ptree, ReadFuncNS, WriteFuncNS>
@@ -84,7 +85,7 @@
generic_parser_test_ok<Ptree, ReadFuncWS, WriteFuncWS>
(
ReadFuncWS(), WriteFuncWS(), ok_data_3, NULL,
- "testok3a.xml", NULL, "testok3aout.xml", 787, 32523, 3831
+ "testok3a.xml", NULL, "testok3aout.xml", 1662, 35377, 11706
);
generic_parser_test_ok<Ptree, ReadFuncNS, WriteFuncNS>
@@ -96,14 +97,14 @@
generic_parser_test_ok<Ptree, ReadFuncWS, WriteFuncWS>
(
ReadFuncWS(), WriteFuncWS(), ok_data_4, NULL,
- "testok4.xml", NULL, "testok4out.xml", 5, 2, 20
+ "testok4.xml", NULL, "testok4out.xml", 11, 7, 74
);
generic_parser_test_ok<Ptree, ReadFuncWS, WriteFuncWS>
(
ReadFuncWS(), WriteFuncWS(), ok_data_5, NULL,
"testok5.xml", NULL, "testok5out.xml",
- 2, umlautsize<typename Ptree::data_type::value_type>(), 3
+ 3, umlautsize<typename Ptree::data_type::value_type>(), 12
);
generic_parser_test_error<Ptree, ReadFuncWS, WriteFuncWS, xml_parser_error>
@@ -118,6 +119,12 @@
"testerr2.xml", NULL, "testerr2out.xml", 2
);
+ generic_parser_test_ok<Ptree, ReadFuncWS, WriteFuncWS>
+ (
+ ReadFuncWS(), WriteFuncWS(), bug_data_pr2855, NULL,
+ "testpr2855.xml", NULL, "testpr2855out.xml", 3, 7, 14
+ );
+
}
#endif
Modified: trunk/libs/property_tree/test/test_xml_parser_rapidxml.cpp
==============================================================================
--- trunk/libs/property_tree/test/test_xml_parser_rapidxml.cpp (original)
+++ trunk/libs/property_tree/test/test_xml_parser_rapidxml.cpp 2010-01-20 13:47:50 EST (Wed, 20 Jan 2010)
@@ -1,5 +1,6 @@
// ----------------------------------------------------------------------------
// Copyright (C) 2002-2006 Marcin Kalicinski
+// Copyright (C) 2009-2010 Sebastian Redl
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
@@ -19,10 +20,10 @@
int test_main(int argc, char *argv[])
{
using namespace boost::property_tree;
- using std::locale;
test_xml_parser<ptree>();
test_xml_parser<iptree>();
#ifndef BOOST_NO_CWCHAR
+ using std::locale;
// We need a UTF-8-aware global locale now.
locale loc(locale(), new utf8_codecvt_facet);
locale::global(loc);
Modified: trunk/libs/property_tree/test/xml_parser_test_data.hpp
==============================================================================
--- trunk/libs/property_tree/test/xml_parser_test_data.hpp (original)
+++ trunk/libs/property_tree/test/xml_parser_test_data.hpp 2010-01-20 13:47:50 EST (Wed, 20 Jan 2010)
@@ -760,4 +760,8 @@
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
"<start>"; // XML tag not closed
+const char *bug_data_pr2855 =
+ "<?xml version=\"1.0\" encoding\"utf-8\"?>\n"
+ "<start> notrim</start>";
+
#endif
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk