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>
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>
29 using namespace boost::bimaps;
31 template< class BimapType >
32 void test_bimap_mutable()
34 typedef BimapType bm_type;
37 bm.insert( BOOST_DEDUCED_TYPENAME bm_type::value_type(1,0.1) );
39 const bm_type & cbm = bm;
41 // Map Mutable Iterator test
44 BOOST_DEDUCED_TYPENAME bm_type::left_iterator iter = bm.left.begin();
46 BOOST_CHECK( iter->second == bm.left.begin()->second );
48 BOOST_DEDUCED_TYPENAME bm_type::left_const_iterator citer = bm.left.begin();
49 BOOST_CHECK( citer->second == bm.left.begin()->second );
51 BOOST_DEDUCED_TYPENAME bm_type::left_const_iterator cciter = cbm.left.begin();
52 BOOST_CHECK( cciter->second == cbm.left.begin()->second );
56 // Set Mutable Iterator test
59 BOOST_DEDUCED_TYPENAME bm_type::iterator iter = bm.begin();
61 BOOST_CHECK( iter->right == bm.begin()->right );
63 BOOST_DEDUCED_TYPENAME bm_type::const_iterator citer = bm.begin();
64 BOOST_CHECK( citer->right == bm.begin()->right );
66 BOOST_DEDUCED_TYPENAME bm_type::const_iterator cciter = cbm.begin();
67 BOOST_CHECK( cciter->left == cbm.begin()->left );
71 // Map Assignable Reference test
74 BOOST_DEDUCED_TYPENAME bm_type::left_reference r = *bm.left.begin();
76 BOOST_CHECK( r == *bm.left.begin() );
78 BOOST_DEDUCED_TYPENAME bm_type::left_const_reference cr = *bm.left.begin();
79 BOOST_CHECK( cr == *bm.left.begin() );
81 BOOST_DEDUCED_TYPENAME bm_type::left_const_reference ccr = *cbm.left.begin();
82 BOOST_CHECK( ccr == *cbm.left.begin() );
86 // Set Assignable Reference test
89 BOOST_DEDUCED_TYPENAME bm_type::reference r = *bm.begin();
91 BOOST_CHECK( r == *bm.begin() );
93 BOOST_DEDUCED_TYPENAME bm_type::const_reference cr = *bm.begin();
94 BOOST_CHECK( cr == *bm.begin() );
96 BOOST_DEDUCED_TYPENAME bm_type::const_reference ccr = *cbm.begin();
97 BOOST_CHECK( ccr == *bm.begin() );
102 int test_main( int, char* [] )
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> > >();