]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/bimap/test/test_bimap_mutable.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / bimap / test / test_bimap_mutable.cpp
1 // Boost.Bimap
2 //
3 // Copyright (c) 2006-2007 Matias Capeletto
4 //
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)
8
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
17
18 #include <boost/config.hpp>
19
20 // Boost.Test
21 #include <boost/test/minimal.hpp>
22
23 // Boost.Bimap
24 #include <boost/bimap/bimap.hpp>
25 #include <boost/bimap/list_of.hpp>
26 #include <boost/bimap/vector_of.hpp>
27 #include <boost/bimap/unconstrained_set_of.hpp>
28
29 using namespace boost::bimaps;
30
31 template< class BimapType >
32 void test_bimap_mutable()
33 {
34 typedef BimapType bm_type;
35
36 bm_type bm;
37 bm.insert( BOOST_DEDUCED_TYPENAME bm_type::value_type(1,0.1) );
38
39 const bm_type & cbm = bm;
40
41 // Map Mutable Iterator test
42 {
43
44 BOOST_DEDUCED_TYPENAME bm_type::left_iterator iter = bm.left.begin();
45 iter->second = 0.2;
46 BOOST_CHECK( iter->second == bm.left.begin()->second );
47
48 BOOST_DEDUCED_TYPENAME bm_type::left_const_iterator citer = bm.left.begin();
49 BOOST_CHECK( citer->second == bm.left.begin()->second );
50
51 BOOST_DEDUCED_TYPENAME bm_type::left_const_iterator cciter = cbm.left.begin();
52 BOOST_CHECK( cciter->second == cbm.left.begin()->second );
53
54 }
55
56 // Set Mutable Iterator test
57 {
58
59 BOOST_DEDUCED_TYPENAME bm_type::iterator iter = bm.begin();
60 iter->right = 0.1;
61 BOOST_CHECK( iter->right == bm.begin()->right );
62
63 BOOST_DEDUCED_TYPENAME bm_type::const_iterator citer = bm.begin();
64 BOOST_CHECK( citer->right == bm.begin()->right );
65
66 BOOST_DEDUCED_TYPENAME bm_type::const_iterator cciter = cbm.begin();
67 BOOST_CHECK( cciter->left == cbm.begin()->left );
68
69 }
70
71 // Map Assignable Reference test
72 {
73
74 BOOST_DEDUCED_TYPENAME bm_type::left_reference r = *bm.left.begin();
75 r.second = 0.2;
76 BOOST_CHECK( r == *bm.left.begin() );
77
78 BOOST_DEDUCED_TYPENAME bm_type::left_const_reference cr = *bm.left.begin();
79 BOOST_CHECK( cr == *bm.left.begin() );
80
81 BOOST_DEDUCED_TYPENAME bm_type::left_const_reference ccr = *cbm.left.begin();
82 BOOST_CHECK( ccr == *cbm.left.begin() );
83
84 }
85
86 // Set Assignable Reference test
87 {
88
89 BOOST_DEDUCED_TYPENAME bm_type::reference r = *bm.begin();
90 r.right = 0.1;
91 BOOST_CHECK( r == *bm.begin() );
92
93 BOOST_DEDUCED_TYPENAME bm_type::const_reference cr = *bm.begin();
94 BOOST_CHECK( cr == *bm.begin() );
95
96 BOOST_DEDUCED_TYPENAME bm_type::const_reference ccr = *cbm.begin();
97 BOOST_CHECK( ccr == *bm.begin() );
98
99 }
100 }
101
102 int test_main( int, char* [] )
103 {
104 test_bimap_mutable< bimap< int, list_of<double> > >();
105 test_bimap_mutable< bimap< int, vector_of<double> > >();
106 test_bimap_mutable< bimap< int, unconstrained_set_of<double> > >();
107 return 0;
108 }
109