]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/property_tree/test/test_property_tree.cpp
1 // ----------------------------------------------------------------------------
2 // Copyright (C) 2002-2006 Marcin Kalicinski
4 // Distributed under the Boost Software License, Version 1.0.
5 // (See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
8 // For more information, see www.boost.org
9 // ----------------------------------------------------------------------------
10 #include "test_utils.hpp"
11 #include <boost/any.hpp>
12 #include <boost/range.hpp>
16 // If using VC, disable some warnings that trip in boost::serialization bowels
18 #pragma warning(disable:4267) // Narrowing conversion
19 #pragma warning(disable:4996) // Deprecated functions
22 #include <boost/archive/text_iarchive.hpp>
23 #include <boost/archive/text_oarchive.hpp>
24 #include <boost/archive/binary_iarchive.hpp>
25 #include <boost/archive/binary_oarchive.hpp>
26 #include <boost/archive/xml_iarchive.hpp>
27 #include <boost/archive/xml_oarchive.hpp>
28 #include <boost/property_tree/ptree_serialization.hpp>
30 // Predicate for sorting keys
34 bool operator()(const typename
Ptree::value_type
&v1
,
35 const typename
Ptree::value_type
&v2
) const
37 return v1
.first
< v2
.first
;
41 // Predicate for sorting keys in reverse
45 bool operator()(const typename
Ptree::value_type
&v1
,
46 const typename
Ptree::value_type
&v2
) const
48 return v1
.first
> v2
.first
;
52 // Custom translator that works with boost::any instead of std::string
56 typedef boost::any internal_type
;
57 typedef E external_type
;
59 boost::optional
<E
> get_value(const internal_type
&v
) {
60 if(const E
*p
= boost::any_cast
<E
>(&v
)) {
63 return boost::optional
<E
>();
65 boost::optional
<internal_type
> put_value(const E
&v
) {
70 namespace boost
{ namespace property_tree
{
72 struct translator_between
<boost::any
, E
>
74 typedef any_translator
<E
> type
;
78 // Include char tests, case sensitive
81 #define PTREE boost::property_tree::ptree
84 # include "test_property_tree.hpp"
91 // Include wchar_t tests, case sensitive
92 #ifndef BOOST_NO_CWCHAR
93 # define CHTYPE wchar_t
95 # define PTREE boost::property_tree::wptree
98 # include "test_property_tree.hpp"
106 // Include char tests, case insensitive
109 #define PTREE boost::property_tree::iptree
112 # include "test_property_tree.hpp"
119 // Include wchar_t tests, case insensitive
120 #ifndef BOOST_NO_CWCHAR
121 # define CHTYPE wchar_t
123 # define PTREE boost::property_tree::wiptree
126 # include "test_property_tree.hpp"
134 template <typename Ptree
>
135 void run_tests(Ptree
* pt
)
138 test_constructor_destructor_assignment(pt
);
143 test_container_iteration(pt
);
145 test_sort_reverse(pt
);
150 test_get_child_put_child(pt
);
151 test_equal_range(pt
);
152 test_path_separator(pt
);
156 test_custom_data_type(pt
);
157 test_empty_size_max_size(pt
);
158 test_ptree_bad_path(pt
);
159 test_ptree_bad_data(pt
);
160 test_serialization(pt
);
165 test_leaks(pt
); // must be a final test
168 int main(int, char *[])
171 using namespace boost::property_tree
;
173 // char tests, case sensitive
179 // wchar_t tests, case sensitive
180 #ifndef BOOST_NO_CWCHAR
187 // char tests, case insensitive
193 // wchar_t tests, case insensitive
194 #ifndef BOOST_NO_CWCHAR
201 return boost::report_errors();