DGtal  0.9.2
testContainerTraits.cpp
1 
32 #include <vector>
33 #include <list>
34 #include <deque>
35 #include <set>
36 #include <map>
37 #include <boost/unordered_set.hpp>
38 #include <boost/unordered_map.hpp>
39 #include <forward_list>
40 #include <array>
41 #include <unordered_set>
42 #include <unordered_map>
43 
44 #include "DGtal/base/Common.h"
45 #include "DGtal/base/ContainerTraits.h"
46 
47 #include "DGtalCatch.h"
48 
49 using namespace DGtal;
50 using namespace std;
51 
52 
53 TEST_CASE( "int container traits", "[int][traits]" )
54 {
55  typedef int Container;
56  SECTION( "Checking container traits" )
57  {
58  REQUIRE( (IsContainer< Container >::value == false) );
59  REQUIRE( (IsSequenceContainer< Container >::value == false) );
60  REQUIRE( (IsAssociativeContainer< Container >::value == false) );
67  }
68 }
69 
70 TEST_CASE( "std::vector<> container traits", "[vector][traits]" )
71 {
72  typedef std::vector<int> Container;
73  SECTION( "Checking container traits" )
74  {
75  REQUIRE( (IsContainer< Container >::value == true) );
76  REQUIRE( (IsSequenceContainer< Container >::value == true) );
77  REQUIRE( (IsAssociativeContainer< Container >::value == false) );
84  }
85 }
86 
87 TEST_CASE( "std::list<> container traits", "[list][traits]" )
88 {
89  typedef std::list<int> Container;
90  SECTION( "Checking container traits" )
91  {
92  REQUIRE( (IsContainer< Container >::value == true) );
93  REQUIRE( (IsSequenceContainer< Container >::value == true) );
94  REQUIRE( (IsAssociativeContainer< Container >::value == false) );
101  }
102 }
103 
104 TEST_CASE( "std::deque<> container traits", "[deque][traits]" )
105 {
106  typedef std::deque<int> Container;
107  SECTION( "Checking container traits" )
108  {
109  REQUIRE( (IsContainer< Container >::value == true) );
110  REQUIRE( (IsSequenceContainer< Container >::value == true) );
111  REQUIRE( (IsAssociativeContainer< Container >::value == false) );
118  }
119 }
120 
121 TEST_CASE( "std::forward_list<> container traits", "[forward_list][traits]" )
122 {
123  typedef std::forward_list<int> Container;
124  SECTION( "Checking container traits" )
125  {
126  REQUIRE( (IsContainer< Container >::value == true) );
127  REQUIRE( (IsSequenceContainer< Container >::value == true) );
128  REQUIRE( (IsAssociativeContainer< Container >::value == false) );
135  }
136 }
137 
138 TEST_CASE( "std::array<> container traits", "[array][traits]" )
139 {
140  typedef std::array<int, 10> Container;
141  SECTION( "Checking container traits" )
142  {
143  REQUIRE( (IsContainer< Container >::value == true) );
144  REQUIRE( (IsSequenceContainer< Container >::value == true) );
145  REQUIRE( (IsAssociativeContainer< Container >::value == false) );
152  }
153 }
154 
155 TEST_CASE( "std::set<> container traits", "[set][traits]" )
156 {
157  typedef std::set<int> Container;
158  SECTION( "Checking container traits" )
159  {
160  REQUIRE( (IsContainer< Container >::value == true) );
161  REQUIRE( (IsSequenceContainer< Container >::value == false) );
162  REQUIRE( (IsAssociativeContainer< Container >::value == true) );
169  }
170 }
171 
172 TEST_CASE( "std::multiset<> container traits", "[multiset][traits]" )
173 {
174  typedef std::multiset<int> Container;
175  SECTION( "Checking container traits" )
176  {
177  REQUIRE( (IsContainer< Container >::value == true) );
178  REQUIRE( (IsSequenceContainer< Container >::value == false) );
179  REQUIRE( (IsAssociativeContainer< Container >::value == true) );
186  }
187 }
188 
189 TEST_CASE( "std::map<> container traits", "[map][traits]" )
190 {
191  typedef std::map<int,int> Container;
192  SECTION( "Checking container traits" )
193  {
194  REQUIRE( (IsContainer< Container >::value == true) );
195  REQUIRE( (IsSequenceContainer< Container >::value == false) );
196  REQUIRE( (IsAssociativeContainer< Container >::value == true) );
203  }
204 }
205 
206 TEST_CASE( "std::multimap<> container traits", "[multimap][traits]" )
207 {
208  typedef std::multimap<int,int> Container;
209  SECTION( "Checking container traits" )
210  {
211  REQUIRE( (IsContainer< Container >::value == true) );
212  REQUIRE( (IsSequenceContainer< Container >::value == false) );
213  REQUIRE( (IsAssociativeContainer< Container >::value == true) );
220  }
221 }
222 
223 TEST_CASE( "boost::unordered_set<> container traits", "[unordered_set][traits]" )
224 {
225  typedef boost::unordered_set<int> Container;
226  SECTION( "Checking container traits" )
227  {
228  REQUIRE( (IsContainer< Container >::value == true) );
229  REQUIRE( (IsSequenceContainer< Container >::value == false) );
230  REQUIRE( (IsAssociativeContainer< Container >::value == true) );
237  }
238 }
239 
240 TEST_CASE( "boost::unordered_map<> container traits", "[unordered_map][traits]" )
241 {
242  typedef boost::unordered_map<int,int> Container;
243  SECTION( "Checking container traits" )
244  {
245  REQUIRE( (IsContainer< Container >::value == true) );
246  REQUIRE( (IsSequenceContainer< Container >::value == false) );
247  REQUIRE( (IsAssociativeContainer< Container >::value == true) );
254  }
255 }
256 
257 TEST_CASE( "boost::unordered_multiset<> container traits", "[unordered_multiset][traits]" )
258 {
259  typedef boost::unordered_multiset<int> Container;
260  SECTION( "Checking container traits" )
261  {
262  REQUIRE( (IsContainer< Container >::value == true) );
263  REQUIRE( (IsSequenceContainer< Container >::value == false) );
264  REQUIRE( (IsAssociativeContainer< Container >::value == true) );
271  }
272 }
273 
274 TEST_CASE( "boost::unordered_multimap<> container traits", "[unordered_multimap][traits]" )
275 {
276  typedef boost::unordered_multimap<int,int> Container;
277  SECTION( "Checking container traits" )
278  {
279  REQUIRE( (IsContainer< Container >::value == true) );
280  REQUIRE( (IsSequenceContainer< Container >::value == false) );
281  REQUIRE( (IsAssociativeContainer< Container >::value == true) );
288  }
289 }
290 
291 TEST_CASE( "std::unordered_set<> container traits", "[unordered_set][traits]" )
292 {
293  typedef std::unordered_set<int> Container;
294  SECTION( "Checking container traits" )
295  {
296  REQUIRE( (IsContainer< Container >::value == true) );
297  REQUIRE( (IsSequenceContainer< Container >::value == false) );
298  REQUIRE( (IsAssociativeContainer< Container >::value == true) );
305  }
306 }
307 TEST_CASE( "std::unordered_multiset<> container traits", "[unordered_multiset][traits]" )
308 {
309  typedef std::unordered_multiset<int> Container;
310  SECTION( "Checking container traits" )
311  {
312  REQUIRE( (IsContainer< Container >::value == true) );
313  REQUIRE( (IsSequenceContainer< Container >::value == false) );
314  REQUIRE( (IsAssociativeContainer< Container >::value == true) );
321  }
322 }
323 
324 TEST_CASE( "std::unordered_map<> container traits", "[unordered_map][traits]" )
325 {
326  typedef std::unordered_map<int,int> Container;
327  SECTION( "Checking container traits" )
328  {
329  REQUIRE( (IsContainer< Container >::value == true) );
330  REQUIRE( (IsSequenceContainer< Container >::value == false) );
331  REQUIRE( (IsAssociativeContainer< Container >::value == true) );
338  }
339 }
340 
341 TEST_CASE( "std::unordered_multimap<> container traits", "[unordered_multimap][traits]" )
342 {
343  typedef std::unordered_multimap<int,int> Container;
344  SECTION( "Checking container traits" )
345  {
346  REQUIRE( (IsContainer< Container >::value == true) );
347  REQUIRE( (IsSequenceContainer< Container >::value == false) );
348  REQUIRE( (IsAssociativeContainer< Container >::value == true) );
355  }
356 }
357 
STL namespace.
DGtal is the top-level namespace which contains all DGtal functions and types.