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 https://web.archive.org/web/20071014014301/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>
21 #include <boost/test/minimal.hpp>
23 #include <boost/config.hpp>
27 #include <boost/bimap/bimap.hpp>
28 #include <boost/bimap/unordered_set_of.hpp>
33 using namespace boost::bimaps;
35 typedef bimap< double, unordered_set_of<int>, with_info<std::string> > bm_type;
38 const bm_type & cbm = bm;
40 // Insertion with info
41 bm .insert( bm_type:: value_type(1.1 , 1, "one" ) );
42 bm.left .insert( bm_type:: left_value_type(2.2 , 2, "two" ) );
43 bm.right.insert( bm_type::right_value_type( 3 , 3.3, "three" ) );
45 bm.begin()->info = "1";
46 BOOST_CHECK( bm.right.find(1)->info == "1" );
48 bm.left.find(2.2)->info = "2";
49 BOOST_CHECK( bm.right.find(2)->info == "2" );
51 bm.right.find(3)->info = "3";
52 BOOST_CHECK( bm.right.find(3)->info == "3" );
55 bm .insert( bm_type:: value_type(4.4 , 4) );
56 bm. left.insert( bm_type:: left_value_type(5.5 , 5) );
57 bm.right.insert( bm_type::right_value_type( 6 , 6.6) );
59 BOOST_CHECK( bm.right.find(4)->info == "" );
61 bm.left.info_at(4.4) = "4";
62 BOOST_CHECK( bm.right.info_at(4) == "4" );
63 BOOST_CHECK( cbm.right.info_at(4) == "4" );
65 bm.right.info_at(5) = "5";
66 BOOST_CHECK( bm.left.info_at(5.5) == "5" );
67 BOOST_CHECK( cbm.left.info_at(5.5) == "5" );
77 int test_tagged_bimap_info()
79 using namespace boost::bimaps;
81 typedef bimap< tagged<int,left>,
83 with_info<tagged<int,info> > > bm_type;
86 const bm_type & cbm = bm;
88 bm .insert( bm_type:: value_type(1,1,1) );
89 bm.left .insert( bm_type:: left_value_type(2,2,2) );
90 bm.right.insert( bm_type::right_value_type(3,3,3) );
92 bm.begin()->get<info>() = 10;
93 BOOST_CHECK( bm.right.find(1)->get<info>() == 10 );
94 BOOST_CHECK( cbm.right.find(1)->get<info>() == 10 );
96 bm.left.find(2)->get<info>() = 20;
97 BOOST_CHECK( bm.right.find(2)->get<info>() == 20 );
98 BOOST_CHECK( cbm.right.find(2)->get<info>() == 20 );
100 bm.right.find(3)->get<info>() = 30;
101 BOOST_CHECK( bm.right.find(3)->get<info>() == 30 );
102 BOOST_CHECK( cbm.right.find(3)->get<info>() == 30 );
105 bm .insert( bm_type:: value_type(4,4) );
106 bm. left.insert( bm_type:: left_value_type(5,5) );
107 bm.right.insert( bm_type::right_value_type(6,6) );
109 bm.left.info_at(4) = 4;
110 BOOST_CHECK( bm.right.info_at(4) == 4 );
111 BOOST_CHECK( cbm.right.info_at(4) == 4 );
113 bm.right.info_at(5) = 5;
114 BOOST_CHECK( bm.left.info_at(5) == 5 );
115 BOOST_CHECK( cbm.left.info_at(5) == 5 );
120 int test_main( int, char* [] )
123 test_tagged_bimap_info();