]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/serialization/test/test_list_ptrs.cpp
ede26880747755e11e98bcfb7f7c83b762bc19dd
1 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
4 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
5 // Use, modification and distribution is subject to the Boost Software
6 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
9 // should pass compilation and execution
14 #include <boost/config.hpp>
15 #include <cstdio> // remove
16 #if defined(BOOST_NO_STDC_NAMESPACE)
22 #include <boost/type_traits/is_pointer.hpp>
23 #include <boost/static_assert.hpp>
24 #include <boost/checked_delete.hpp>
26 #include <boost/archive/archive_exception.hpp>
27 #include "test_tools.hpp"
29 #include <boost/serialization/nvp.hpp>
36 BOOST_STATIC_ASSERT(::boost::is_pointer
< T
>::value
);
37 bool operator()(T
const _Left
, T
const _Right
) const
39 if(NULL
== _Left
&& NULL
== _Right
)
41 if(typeid(*_Left
) != typeid(*_Right
))
43 return *_Left
== *_Right
;
47 #include <boost/serialization/list.hpp>
49 const char * testfile
= boost::archive::tmpnam(NULL
);
50 BOOST_REQUIRE(NULL
!= testfile
);
54 test_ostream
os(testfile
, TEST_STREAM_FLAGS
);
55 test_oarchive
oa(os
, TEST_ARCHIVE_FLAGS
);
56 A
* free_a_ptr
= new A
;
57 alist
.push_back(free_a_ptr
);
58 alist
.push_back(new A
);
59 // verify that first element is the same as the free pointer
60 BOOST_CHECK((*alist
.begin()) == free_a_ptr
);
61 oa
<< boost::serialization::make_nvp("alist", alist
);
62 oa
<< boost::serialization::make_nvp("free_a_ptr", free_a_ptr
);
64 std::list
<A
*> alist1
;
66 test_istream
is(testfile
, TEST_STREAM_FLAGS
);
67 test_iarchive
ia(is
, TEST_ARCHIVE_FLAGS
);
69 ia
>> boost::serialization::make_nvp("alist", alist1
);
70 ia
>> boost::serialization::make_nvp("free_a_ptr", free_a_ptr1
);
72 alist
.size() == alist1
.size()
73 && std::equal(alist
.begin(),alist
.end(),alist1
.begin(),ptr_equal_to
<A
*>())
75 // verify that first element is the same as the free pointer
76 BOOST_CHECK((*alist1
.begin()) == free_a_ptr1
);
82 boost::checked_deleter
<A
>()
87 boost::checked_deleter
<A
>()
89 std::remove(testfile
);
92 int test_main( int /* argc */, char* /* argv */[] )