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 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
17
18 #include <boost/config.hpp>
19
20 #include <boost/core/lightweight_test.hpp>
21
22 // Boost.Bimap
23 #include <boost/bimap/support/lambda.hpp>
24 #include <boost/bimap/bimap.hpp>
25
26
test_bimap_unconstrained()27 void test_bimap_unconstrained()
28 {
29 using namespace boost::bimaps;
30
31 {
32 typedef bimap<int,double,unconstrained_set_of_relation> bm;
33 bm b;
34 b.left.insert( bm::left_value_type(2,34.4) );
35 b.right.insert( bm::right_value_type(2.2,3) );
36 }
37
38 {
39 typedef bimap<int,unconstrained_set_of<double> > bm;
40 bm b;
41 b.insert( bm::value_type(2,34.4) );
42 BOOST_TEST( b.size() == 1 );
43 }
44
45 {
46 typedef bimap<unconstrained_set_of<int>, double > bm;
47 bm b;
48 b.right[2.4] = 34;
49 BOOST_TEST( b.right.size() == 1 );
50 }
51
52 {
53 typedef bimap<unconstrained_set_of<int>, double, right_based > bm;
54 bm b;
55 b.right[2.4] = 34;
56 BOOST_TEST( b.right.size() == 1 );
57 }
58
59 {
60 typedef bimap
61 <
62 int,
63 unconstrained_set_of<double>,
64 unconstrained_set_of_relation
65
66 > bm;
67
68 bm b;
69 b.left[2] = 34.4;
70 BOOST_TEST( b.left.size() == 1 );
71 }
72
73 {
74 typedef bimap
75 <
76 unconstrained_set_of<int>,
77 double,
78 unconstrained_set_of_relation
79
80 > bm;
81
82 bm b;
83 b.right[2.4] = 34;
84 BOOST_TEST( b.right.size() == 1 );
85 }
86
87 {
88 typedef bimap
89 <
90 unconstrained_set_of<int>,
91 unconstrained_set_of<double>,
92 set_of_relation<>
93
94 > bm;
95
96 bm b;
97 b.insert( bm::value_type(1,2.3) );
98 BOOST_TEST( b.size() == 1 );
99 }
100 }
101
102
main()103 int main()
104 {
105 test_bimap_unconstrained();
106 return boost::report_errors();
107 }
108
109