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>
20 #define BOOST_BIMAP_DISABLE_SERIALIZATION
23 #include <boost/test/minimal.hpp>
31 // Set type specifications
32 #include <boost/bimap/set_of.hpp>
33 #include <boost/bimap/multiset_of.hpp>
36 #include <boost/bimap/bimap.hpp>
38 #include <libs/bimap/test/test_bimap.hpp>
45 using namespace boost::bimaps;
47 typedef std::map<int,double> left_data_type;
48 left_data_type left_data;
49 left_data.insert( left_data_type::value_type(1,0.1) );
50 left_data.insert( left_data_type::value_type(2,0.2) );
51 left_data.insert( left_data_type::value_type(3,0.3) );
52 left_data.insert( left_data_type::value_type(4,0.4) );
54 typedef std::map<double,int> right_data_type;
55 right_data_type right_data;
56 right_data.insert( right_data_type::value_type(0.1,1) );
57 right_data.insert( right_data_type::value_type(0.2,2) );
58 right_data.insert( right_data_type::value_type(0.3,3) );
59 right_data.insert( right_data_type::value_type(0.4,4) );
62 //--------------------------------------------------------------------
64 typedef bimap< int, double > bm_type;
66 std::set< bm_type::value_type > data;
67 data.insert( bm_type::value_type(1,0.1) );
68 data.insert( bm_type::value_type(2,0.2) );
69 data.insert( bm_type::value_type(3,0.3) );
70 data.insert( bm_type::value_type(4,0.4) );
73 test_set_set_bimap(bm,data,left_data,right_data);
75 //--------------------------------------------------------------------
78 //--------------------------------------------------------------------
82 multiset_of< tagged<int, left_tag > >,
83 multiset_of< tagged<double, right_tag > >,
84 multiset_of_relation< std::less< _relation > >
88 std::set< bm_type::value_type > data;
89 data.insert( bm_type::value_type(1,0.1) );
90 data.insert( bm_type::value_type(2,0.2) );
91 data.insert( bm_type::value_type(3,0.3) );
92 data.insert( bm_type::value_type(4,0.4) );
96 test_multiset_multiset_bimap(bm,data,left_data,right_data);
97 test_tagged_bimap<left_tag,right_tag>(bm,data);
99 //--------------------------------------------------------------------
102 //--------------------------------------------------------------------
104 typedef bimap<int,double,right_based> bm_type;
106 std::set< bm_type::value_type > data;
107 data.insert( bm_type::value_type(1,0.1) );
108 data.insert( bm_type::value_type(2,0.2) );
109 data.insert( bm_type::value_type(3,0.3) );
110 data.insert( bm_type::value_type(4,0.4) );
114 test_set_set_bimap(bm,data,left_data,right_data);
116 //--------------------------------------------------------------------
119 //--------------------------------------------------------------------
123 multiset_of< int, std::greater<int> >, set_of<std::string> ,
124 multiset_of_relation< std::greater< _relation > >
130 b1.insert( bimap_type::value_type(1,"one") );
134 BOOST_CHECK( b1 == b2 );
135 BOOST_CHECK( ! ( b1 != b2 ) );
136 BOOST_CHECK( b1 <= b2 );
137 BOOST_CHECK( b1 >= b2 );
138 BOOST_CHECK( ! ( b1 < b2 ) );
139 BOOST_CHECK( ! ( b1 > b2 ) );
141 b1.insert( bimap_type::value_type(2,"two") );
144 BOOST_CHECK( b2 == b1 );
146 b1.insert( bimap_type::value_type(3,"three") );
149 BOOST_CHECK( b2 == b1 );
151 b1.insert( bimap_type::value_type(4,"four") );
154 BOOST_CHECK( b2 == b1 );
158 BOOST_CHECK( b2.empty() && !b1.empty() );
160 b1.left.swap( b2.left );
161 BOOST_CHECK( b1.empty() && !b2.empty() );
163 b1.right.swap( b2.right );
164 BOOST_CHECK( b2.empty() && !b1.empty() );
166 //--------------------------------------------------------------------
171 int test_main( int, char* [] )