Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / bimap / test / test_bimap_unordered.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 #define BOOST_BIMAP_DISABLE_SERIALIZATION
21
22 // Boost.Test
23 #include <boost/test/minimal.hpp>
24
25 // std
26 #include <set>
27 #include <map>
28 #include <string>
29 #include <functional>
30
31 // Set type specifications
32 #include <boost/bimap/unordered_set_of.hpp>
33 #include <boost/bimap/unordered_multiset_of.hpp>
34
35 // bimap container
36 #include <boost/bimap/bimap.hpp>
37
38 #include <libs/bimap/test/test_bimap.hpp>
39
40 struct  left_tag {};
41 struct right_tag {};
42
43 void test_bimap()
44 {
45     using namespace boost::bimaps;
46
47
48     typedef std::map<char,std::string> left_data_type;
49     left_data_type left_data;
50     left_data.insert( left_data_type::value_type('a',"a") );
51     left_data.insert( left_data_type::value_type('b',"b") );
52     left_data.insert( left_data_type::value_type('c',"c") );
53     left_data.insert( left_data_type::value_type('d',"e") );
54
55     typedef std::map<std::string,char> right_data_type;
56     right_data_type right_data;
57     right_data.insert( right_data_type::value_type("a",'a') );
58     right_data.insert( right_data_type::value_type("b",'b') );
59     right_data.insert( right_data_type::value_type("c",'c') );
60     right_data.insert( right_data_type::value_type("d",'e') );
61
62
63
64     //--------------------------------------------------------------------
65     {
66         typedef bimap<
67             unordered_set_of<char>, unordered_multiset_of<std::string>
68
69         > bm_type;
70
71         std::set< bm_type::value_type > data;
72         data.insert( bm_type::value_type('a',"a") );
73         data.insert( bm_type::value_type('b',"b") );
74         data.insert( bm_type::value_type('c',"c") );
75         data.insert( bm_type::value_type('d',"d") );
76
77         bm_type bm;
78
79         test_unordered_set_unordered_multiset_bimap(
80             bm,data,left_data,right_data
81         );
82     }
83     //--------------------------------------------------------------------
84
85
86     //--------------------------------------------------------------------
87     {
88         typedef bimap<
89                  unordered_set_of< tagged< char       , left_tag  > >,
90             unordered_multiset_of< tagged< std::string, right_tag > >
91
92         > bm_type;
93
94         std::set< bm_type::value_type > data;
95         data.insert( bm_type::value_type('a',"a") );
96         data.insert( bm_type::value_type('b',"b") );
97         data.insert( bm_type::value_type('c',"c") );
98         data.insert( bm_type::value_type('d',"d") );
99
100         bm_type bm;
101
102         test_unordered_set_unordered_multiset_bimap(
103             bm,data,left_data,right_data
104         );
105         test_tagged_bimap<left_tag,right_tag>(bm,data);
106     }
107     //--------------------------------------------------------------------
108
109
110     //--------------------------------------------------------------------
111     {
112         typedef bimap
113         <
114             set_of< char, std::greater<char> >,
115             unordered_multiset_of<std::string>,
116             unordered_set_of_relation<>
117
118         > bm_type;
119
120         std::set< bm_type::value_type > data;
121         data.insert( bm_type::value_type('a',"a") );
122         data.insert( bm_type::value_type('b',"b") );
123         data.insert( bm_type::value_type('c',"c") );
124         data.insert( bm_type::value_type('d',"d") );
125
126         bm_type bm;
127
128         test_basic_bimap(bm,data,left_data,right_data);
129         test_associative_container(bm,data);
130         test_simple_unordered_associative_container(bm,data);
131     }
132     //--------------------------------------------------------------------
133
134
135     //--------------------------------------------------------------------
136     {
137                 typedef bimap
138         <
139             unordered_multiset_of< char >,
140             unordered_multiset_of< std::string >,
141             unordered_multiset_of_relation<>
142
143         > bm_type;
144
145         std::set< bm_type::value_type > data;
146         data.insert( bm_type::value_type('a',"a") );
147         data.insert( bm_type::value_type('b',"b") );
148         data.insert( bm_type::value_type('c',"c") );
149         data.insert( bm_type::value_type('d',"d") );
150
151         bm_type bm;
152
153         test_basic_bimap(bm,data,left_data,right_data);
154         test_associative_container(bm,data);
155         test_simple_unordered_associative_container(bm,data);
156
157     }
158     //--------------------------------------------------------------------
159 }
160
161
162 int test_main( int, char* [] )
163 {
164     test_bimap();
165     return 0;
166 }
167