3 // Copyright (c) 2006-2007 Matias Capeletto
5 // Distributed under the Boost Software License, Version 1.0.
6 // (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
9 // VC++ 8.0 warns on usage of certain Standard Library and API functions that
10 // can be cause buffer overruns or other possible security issues if misused.
11 // See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx
12 // But the wording of the warning is misleading and unsettling, there are no
13 // portable alternative functions, and VC++ 8.0's own libraries use the
14 // functions in question. So turn off the warnings.
15 #define _CRT_SECURE_NO_DEPRECATE
16 #define _SCL_SECURE_NO_DEPRECATE
18 #include <boost/config.hpp>
30 #include <boost/test/minimal.hpp>
33 #include <boost/archive/text_oarchive.hpp>
34 #include <boost/archive/text_iarchive.hpp>
37 #include <boost/bimap/bimap.hpp>
40 template< class Bimap
, class Archive
>
41 void save_bimap(const Bimap
& b
, Archive
& ar
)
43 using namespace boost::bimaps
;
47 const typename
Bimap::left_const_iterator left_iter
= b
.left
.begin();
50 const typename
Bimap::const_iterator iter
= ++b
.begin();
57 void test_bimap_serialization()
59 using namespace boost::bimaps
;
61 typedef bimap
<int,double> bm
;
63 std::set
< bm::value_type
> data
;
64 data
.insert( bm::value_type(1,0.1) );
65 data
.insert( bm::value_type(2,0.2) );
66 data
.insert( bm::value_type(3,0.3) );
67 data
.insert( bm::value_type(4,0.4) );
69 std::ostringstream oss
;
75 b
.insert(data
.begin(),data
.end());
77 boost::archive::text_oarchive
oa(oss
);
86 std::istringstream
iss(oss
.str());
87 boost::archive::text_iarchive
ia(iss
);
91 BOOST_CHECK( std::equal( b
.begin(), b
.end(), data
.begin() ) );
93 bm::left_const_iterator left_iter
;
97 BOOST_CHECK( left_iter
== b
.left
.begin() );
99 bm::const_iterator iter
;
103 BOOST_CHECK( iter
== ++b
.begin() );
109 int test_main( int, char* [] )
111 test_bimap_serialization();