Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / bimap / test / test_bimap_assign.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 // std
24 #include <sstream>
25 #include <algorithm>
26 #include <set>
27
28 // Boost
29 #include <boost/assign/list_of.hpp>
30 #include <boost/assign/list_inserter.hpp>
31
32 // Boost.Bimap
33 #include <boost/bimap/list_of.hpp>
34 #include <boost/bimap/unordered_multiset_of.hpp>
35 #include <boost/bimap/vector_of.hpp>
36 #include <boost/bimap/bimap.hpp>
37
38 namespace ba =  boost::assign;
39
40
41 void test_bimap_assign()
42 {
43     using namespace boost::bimaps;
44
45     // test
46     {
47         typedef bimap< list_of<int>, double > bm_type;
48         bm_type bm = ba::list_of< bm_type::relation >(1,0.1)(2,0.2)(3,0.3);
49         ba::push_back( bm )(4,0.4)(5,0.5);
50         ba::insert( bm.right )(0.5,5)(0.6,6);
51         ba::push_back( bm.left )(6,0.6)(7,0.7);
52     }
53
54     // test
55     {
56         typedef bimap< unordered_multiset_of<int>, vector_of<double>,
57                        list_of_relation > bm_type;
58         bm_type bm = ba::list_of< bm_type::relation >(1,0.1)(2,0.2)(3,0.3);
59         ba::push_front( bm )(4,0.4)(5,0.5);
60         ba::push_back( bm.right )(0.6,6)(0.7,7);
61         ba::insert( bm.left )(8,0.8)(9,0.9);
62     }
63
64     // test
65     {
66         typedef bimap< int, vector_of<double>, right_based > bm_type;
67         bm_type bm = ba::list_of< bm_type::relation >(1,0.1)(2,0.2)(3,0.3);
68         ba::push_back( bm )(4,0.4)(5,0.5);
69         ba::push_back( bm.right )(0.6,6)(0.7,7);
70         ba::insert( bm.left )(8,0.8)(9,0.9);
71     }
72
73     // test
74     {
75         typedef bimap< int, vector_of<double>, set_of_relation<> > bm_type;
76         bm_type bm = ba::list_of< bm_type::relation >(1,0.1)(2,0.2)(3,0.3);
77         ba::insert( bm )(4,0.4)(5,0.5);
78         ba::push_back( bm.right )(0.6,6)(0.7,7);
79         ba::insert( bm.left )(8,0.8)(9,0.9);
80     }
81 }
82
83
84 int test_main( int, char* [] )
85 {
86     test_bimap_assign();
87     return 0;
88 }
89