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