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