]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/dynamic_bitset/test/dyn_bitset_unit_tests5.cpp
1 // -----------------------------------------------------------
2 // Copyright (c) 2001 Jeremy Siek
3 // Copyright (c) 2003-2006 Gennaro Prota
5 // Copyright (c) 2015 Seth Heeren
7 // Distributed under the Boost Software License, Version 1.0.
8 // (See accompanying file LICENSE_1_0.txt or copy at
9 // http://www.boost.org/LICENSE_1_0.txt)
11 // -----------------------------------------------------------
13 #include "boost/config.hpp"
14 #if !defined (BOOST_NO_STRINGSTREAM)
18 #include "bitset_test.hpp"
19 #include "boost/dynamic_bitset/serialization.hpp"
20 #include "boost/detail/workaround.hpp"
23 // Codewarrior 8.3 for Win fails without this.
24 // Thanks Howard Hinnant ;)
25 #if defined __MWERKS__ && BOOST_WORKAROUND(__MWERKS__, <= 0x3003) // 8.x
26 # pragma parse_func_templ off
30 #if defined BOOST_NO_STD_WSTRING || defined BOOST_NO_STD_LOCALE
31 # define BOOST_DYNAMIC_BITSET_NO_WCHAR_T_TESTS
34 #include <boost/archive/binary_oarchive.hpp>
35 #include <boost/archive/binary_iarchive.hpp>
36 #include <boost/archive/xml_oarchive.hpp>
37 #include <boost/archive/xml_iarchive.hpp>
41 template <typename Block
>
42 struct SerializableType
{
43 boost::dynamic_bitset
<Block
> x
;
46 friend class boost::serialization::access
;
47 template <class Archive
> void serialize(Archive
&ar
, const unsigned int) {
48 ar
& BOOST_SERIALIZATION_NVP(x
);
52 template <typename Block
, typename IArchive
, typename OArchive
>
53 void test_serialization( BOOST_EXPLICIT_TEMPLATE_TYPE(Block
) )
55 SerializableType
<Block
> a
;
57 for (int i
=0; i
<128; ++i
)
58 a
.x
.resize(11*i
, i
%2);
60 #if !defined (BOOST_NO_STRINGSTREAM)
66 oa
<< BOOST_SERIALIZATION_NVP(a
);
69 // test de-serialization
72 SerializableType
<Block
> b
;
73 ia
>> BOOST_SERIALIZATION_NVP(b
);
78 # error "TODO implement file-based test path?"
82 template <typename Block
>
83 void test_binary_archive( BOOST_EXPLICIT_TEMPLATE_TYPE(Block
) ) {
84 test_serialization
<Block
, boost::archive::binary_iarchive
, boost::archive::binary_oarchive
>();
87 template <typename Block
>
88 void test_xml_archive( BOOST_EXPLICIT_TEMPLATE_TYPE(Block
) ) {
89 test_serialization
<Block
, boost::archive::xml_iarchive
, boost::archive::xml_oarchive
>();
93 template <typename Block
>
94 void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block
) )
96 test_binary_archive
<Block
>();
97 test_xml_archive
<Block
>();
100 int test_main(int, char*[])
102 run_test_cases
<unsigned char>();
103 run_test_cases
<unsigned short>();
104 run_test_cases
<unsigned int>();
105 run_test_cases
<unsigned long>();
106 # ifdef BOOST_HAS_LONG_LONG
107 run_test_cases
< ::boost::ulong_long_type
>();