|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r75590 - in trunk: boost/property_tree/detail libs/property_tree/test
From: sebastian.redl_at_[hidden]
Date: 2011-11-21 07:52:14
Author: cornedbee
Date: 2011-11-21 07:52:12 EST (Mon, 21 Nov 2011)
New Revision: 75590
URL: http://svn.boost.org/trac/boost/changeset/75590
Log:
Suppress the MSVC insecure warning when compiling tests. Make argument-less sort() work. See bug #5710.
Text files modified:
trunk/boost/property_tree/detail/ptree_implementation.hpp | 13 ++++++++++++-
trunk/libs/property_tree/test/Jamfile.v2 | 19 ++++++++++++-------
trunk/libs/property_tree/test/test_property_tree.cpp | 4 ++++
trunk/libs/property_tree/test/test_property_tree.hpp | 25 +++++++++++++++++++++++++
4 files changed, 53 insertions(+), 8 deletions(-)
Modified: trunk/boost/property_tree/detail/ptree_implementation.hpp
==============================================================================
--- trunk/boost/property_tree/detail/ptree_implementation.hpp (original)
+++ trunk/boost/property_tree/detail/ptree_implementation.hpp 2011-11-21 07:52:12 EST (Mon, 21 Nov 2011)
@@ -385,10 +385,21 @@
subs::ch(this).reverse();
}
+ namespace impl
+ {
+ struct by_first
+ {
+ template <typename P>
+ bool operator ()(const P& lhs, const P& rhs) const {
+ return lhs.first < rhs.first;
+ };
+ };
+ }
+
template<class K, class D, class C> inline
void basic_ptree<K, D, C>::sort()
{
- subs::ch(this).sort();
+ sort(impl::by_first());
}
template<class K, class D, class C>
Modified: trunk/libs/property_tree/test/Jamfile.v2
==============================================================================
--- trunk/libs/property_tree/test/Jamfile.v2 (original)
+++ trunk/libs/property_tree/test/Jamfile.v2 2011-11-21 07:52:12 EST (Mon, 21 Nov 2011)
@@ -10,12 +10,17 @@
import testing ;
test-suite "property_tree"
- : [ run test_property_tree.cpp /boost/serialization//boost_serialization ]
- [ run test_info_parser.cpp ]
- [ run test_json_parser.cpp ]
- [ run test_ini_parser.cpp ]
- [ run test_xml_parser_rapidxml.cpp ]
+ : [ run test_property_tree.cpp /boost/serialization//boost_serialization
+ : : : <define>_SCL_SECURE_NO_WARNINGS=1 ]
+ [ run test_info_parser.cpp
+ : : : <define>_SCL_SECURE_NO_WARNINGS=1 ]
+ [ run test_json_parser.cpp
+ : : : <define>_SCL_SECURE_NO_WARNINGS=1 ]
+ [ run test_ini_parser.cpp
+ : : : <define>_SCL_SECURE_NO_WARNINGS=1 ]
+ [ run test_xml_parser_rapidxml.cpp
+ : : : <define>_SCL_SECURE_NO_WARNINGS=1 ]
- [ run test_multi_module1.cpp test_multi_module2.cpp ]
- #[ run test_registry_parser.cpp ]
+ [ run test_multi_module1.cpp test_multi_module2.cpp
+ : : : <define>_SCL_SECURE_NO_WARNINGS=1 ]
;
Modified: trunk/libs/property_tree/test/test_property_tree.cpp
==============================================================================
--- trunk/libs/property_tree/test/test_property_tree.cpp (original)
+++ trunk/libs/property_tree/test/test_property_tree.cpp 2011-11-21 07:52:12 EST (Mon, 21 Nov 2011)
@@ -166,6 +166,7 @@
test_serialization(pt);
test_bool(pt);
test_char(pt);
+ test_sort(pt);
test_leaks(pt); // must be a final test
}
#if 0
@@ -199,6 +200,7 @@
test_serialization(pt);
test_bool(pt);
test_char(pt);
+ test_sort(pt);
test_leaks(pt); // must be a final test
}
#endif
@@ -232,6 +234,7 @@
test_serialization(pt);
test_bool(pt);
test_char(pt);
+ test_sort(pt);
test_leaks(pt); // must be a final test
}
@@ -265,6 +268,7 @@
test_serialization(pt);
test_bool(pt);
test_char(pt);
+ test_sort(pt);
test_leaks(pt); // must be a final test
}
#endif
Modified: trunk/libs/property_tree/test/test_property_tree.hpp
==============================================================================
--- trunk/libs/property_tree/test/test_property_tree.hpp (original)
+++ trunk/libs/property_tree/test/test_property_tree.hpp 2011-11-21 07:52:12 EST (Mon, 21 Nov 2011)
@@ -1290,6 +1290,31 @@
}
+void test_sort(PTREE *)
+{
+ PTREE pt;
+ pt.put(T("one"), T("v1"));
+ pt.put(T("two"), T("v2"));
+ pt.put(T("three"), T("v3"));
+ pt.put(T("four"), T("v4"));
+
+ pt.sort();
+
+ PTREE::iterator it = pt.begin();
+ BOOST_CHECK(std::distance(it, pt.end()) == 4);
+ BOOST_CHECK(it->first == T("four"));
+ BOOST_CHECK(it->second.data() == T("v4"));
+ ++it;
+ BOOST_CHECK(it->first == T("one"));
+ BOOST_CHECK(it->second.data() == T("v1"));
+ ++it;
+ BOOST_CHECK(it->first == T("three"));
+ BOOST_CHECK(it->second.data() == T("v3"));
+ ++it;
+ BOOST_CHECK(it->first == T("two"));
+ BOOST_CHECK(it->second.data() == T("v2"));
+}
+
void test_leaks(PTREE *)
{
//BOOST_CHECK(PTREE::debug_get_instances_count() == 0);
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