1 // Boost.Container static_vector
4 // Copyright (c) 2012-2013 Adam Wulkiewicz, Lodz, Poland.
5 // Copyright (c) 2012-2013 Andrew Hundt.
7 // Use, modification and distribution is subject to the Boost Software License,
8 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
9 // http://www.boost.org/LICENSE_1_0.txt)
10 #include <boost/container/detail/config_begin.hpp>
11 #include <boost/core/lightweight_test.hpp>
12 #include <boost/core/no_exceptions_support.hpp>
13 #include <boost/container/vector.hpp>
14 #include <boost/container/stable_vector.hpp>
15 #include <boost/container/detail/iterator.hpp>
16 #include "../../intrusive/test/iterator_test.hpp"
21 #include "static_vector_test.hpp"
26 //Explicit instantiation to detect compilation errors
27 template class boost::container::static_vector
<int, 10>;
32 template <typename T
, size_t N
>
35 static_vector
<T
, N
> s
;
36 BOOST_STATIC_ASSERT((static_vector
<T
, N
>::static_capacity
) == N
);
37 BOOST_TEST_EQ(s
.size() , 0u);
38 BOOST_TEST(s
.capacity() == N
);
39 BOOST_TEST(s
.max_size() == N
);
40 BOOST_TEST_THROWS( s
.at(0u), std::out_of_range
);
43 template <typename T
, size_t N
>
44 void test_ctor_nc(size_t n
)
46 static_vector
<T
, N
> s(n
);
47 BOOST_STATIC_ASSERT((static_vector
<T
, N
>::static_capacity
) == N
);
48 BOOST_TEST(s
.size() == n
);
49 BOOST_TEST(s
.capacity() == N
);
50 BOOST_TEST(s
.max_size() == N
);
51 BOOST_TEST_THROWS( s
.at(n
), std::out_of_range
);
56 BOOST_TEST(T(10) == s
[0]);
57 BOOST_TEST(T(10) == s
.at(0));
60 BOOST_TEST(T(20) == s
[1]);
61 BOOST_TEST(T(20) == s
.at(1));
65 template <typename T
, size_t N
>
66 void test_ctor_nd(size_t n
, T
const& v
)
68 static_vector
<T
, N
> s(n
, v
);
69 BOOST_STATIC_ASSERT((static_vector
<T
, N
>::static_capacity
) == N
);
70 BOOST_TEST(s
.size() == n
);
71 BOOST_TEST(s
.capacity() == N
);
72 BOOST_TEST_THROWS( s
.at(n
), std::out_of_range
);
75 BOOST_TEST(v
== s
[0]);
76 BOOST_TEST(v
== s
.at(0));
77 BOOST_TEST(v
== s
[1]);
78 BOOST_TEST(v
== s
.at(1));
80 BOOST_TEST(T(10) == s
[0]);
81 BOOST_TEST(T(10) == s
.at(0));
83 BOOST_TEST(T(20) == s
[1]);
84 BOOST_TEST(T(20) == s
.at(1));
88 void test_support_for_initializer_list()
90 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
92 static_vector
<int, 2> sv
= {10, 8};
93 BOOST_TEST(10 == sv
[0]);
94 BOOST_TEST(8 == sv
[1]);
96 typedef static_vector
<int, 1> sv_cap_1
;
97 BOOST_TEST_THROWS(sv_cap_1({1, 1}), std::bad_alloc
);
101 static_vector
<int, 2> sv
;
103 BOOST_TEST(1 == sv
[0]);
104 BOOST_TEST(2 == sv
[1]);
106 BOOST_TEST_THROWS(sv
.assign({1, 2, 3}), std::bad_alloc
);
108 static_vector
<int, 3> greaterThanSv
= {1, 2, 3};
109 BOOST_TEST_THROWS(sv
= greaterThanSv
, std::bad_alloc
);
113 static_vector
<int, 2> sv
;
114 sv
.insert(sv
.begin(), {99, 95});
115 BOOST_TEST(99 == sv
[0]);
116 BOOST_TEST(95 == sv
[1]);
118 BOOST_TEST_THROWS(sv
.insert(sv
.begin(), {101, 102, 103}), std::bad_alloc
);
123 template <typename T
, size_t N
>
124 void test_resize_nc(size_t n
)
126 static_vector
<T
, N
> s
;
129 BOOST_TEST(s
.size() == n
);
130 BOOST_TEST(s
.capacity() == N
);
131 BOOST_TEST_THROWS( s
.at(n
), std::out_of_range
);
136 BOOST_TEST(T(10) == s
[0]);
137 BOOST_TEST(T(10) == s
.at(0));
140 BOOST_TEST(T(20) == s
[1]);
141 BOOST_TEST(T(20) == s
.at(1));
145 template <typename T
, size_t N
>
146 void test_resize_nd(size_t n
, T
const& v
)
148 static_vector
<T
, N
> s
;
151 BOOST_TEST(s
.size() == n
);
152 BOOST_TEST(s
.capacity() == N
);
153 BOOST_TEST_THROWS( s
.at(n
), std::out_of_range
);
156 BOOST_TEST(v
== s
[0]);
157 BOOST_TEST(v
== s
.at(0));
158 BOOST_TEST(v
== s
[1]);
159 BOOST_TEST(v
== s
.at(1));
161 BOOST_TEST(T(10) == s
[0]);
162 BOOST_TEST(T(10) == s
.at(0));
164 BOOST_TEST(T(20) == s
[1]);
165 BOOST_TEST(T(20) == s
.at(1));
169 template <typename T
, size_t N
>
170 void test_push_back_nd()
172 static_vector
<T
, N
> s
;
174 BOOST_TEST(s
.size() == 0);
175 BOOST_TEST_THROWS( s
.at(0), std::out_of_range
);
177 for ( size_t i
= 0 ; i
< N
; ++i
)
181 BOOST_TEST(s
.size() == i
+ 1);
182 BOOST_TEST_THROWS( s
.at(i
+ 1), std::out_of_range
);
183 BOOST_TEST(T(i
) == s
.at(i
));
184 BOOST_TEST(T(i
) == s
[i
]);
185 BOOST_TEST(T(i
) == s
.back());
186 BOOST_TEST(T(0) == s
.front());
187 BOOST_TEST(T(i
) == *(s
.data() + i
));
191 template <typename T
, size_t N
>
192 void test_pop_back_nd()
194 static_vector
<T
, N
> s
;
196 for ( size_t i
= 0 ; i
< N
; ++i
)
202 for ( size_t i
= N
; i
> 1 ; --i
)
205 BOOST_TEST(s
.size() == i
- 1);
206 BOOST_TEST_THROWS( s
.at(i
- 1), std::out_of_range
);
207 BOOST_TEST(T(i
- 2) == s
.at(i
- 2));
208 BOOST_TEST(T(i
- 2) == s
[i
- 2]);
209 BOOST_TEST(T(i
- 2) == s
.back());
210 BOOST_TEST(T(0) == s
.front());
214 template <typename It1
, typename It2
>
215 void test_compare_ranges(It1 first1
, It1 last1
, It2 first2
, It2 last2
)
217 BOOST_TEST(boost::container::iterator_distance(first1
, last1
) == boost::container::iterator_distance(first2
, last2
));
218 for ( ; first1
!= last1
&& first2
!= last2
; ++first1
, ++first2
)
219 BOOST_TEST(*first1
== *first2
);
222 template <typename T
, size_t N
, typename C
>
223 void test_copy_and_assign(C
const& c
)
226 static_vector
<T
, N
> s(c
.begin(), c
.end());
227 BOOST_TEST(s
.size() == c
.size());
228 test_compare_ranges(s
.begin(), s
.end(), c
.begin(), c
.end());
231 static_vector
<T
, N
> s
;
232 BOOST_TEST(0 == s
.size());
233 s
.assign(c
.begin(), c
.end());
234 BOOST_TEST(s
.size() == c
.size());
235 test_compare_ranges(s
.begin(), s
.end(), c
.begin(), c
.end());
239 template <typename T
, size_t N
>
240 void test_copy_and_assign_nd(T
const& val
)
242 static_vector
<T
, N
> s
;
246 for ( size_t i
= 0 ; i
< N
; ++i
)
255 static_vector
<T
, N
> s1(s
);
256 BOOST_TEST(s
.size() == s1
.size());
257 test_compare_ranges(s
.begin(), s
.end(), s1
.begin(), s1
.end());
261 static_vector
<T
, N
> s1
;
262 BOOST_TEST(0 == s1
.size());
264 BOOST_TEST(s
.size() == s1
.size());
265 test_compare_ranges(s
.begin(), s
.end(), s1
.begin(), s1
.end());
268 // ctor(Iter, Iter) and assign(Iter, Iter)
269 test_copy_and_assign
<T
, N
>(s
);
270 test_copy_and_assign
<T
, N
>(v
);
271 test_copy_and_assign
<T
, N
>(l
);
275 static_vector
<T
, N
> s1(s
);
276 test_compare_ranges(s
.begin(), s
.end(), s1
.begin(), s1
.end());
277 std::vector
<T
> a(N
, val
);
279 test_compare_ranges(a
.begin(), a
.end(), s1
.begin(), s1
.end());
282 stable_vector
<T
> bsv(s
.begin(), s
.end());
283 vector
<T
> bv(s
.begin(), s
.end());
284 test_copy_and_assign
<T
, N
>(bsv
);
285 test_copy_and_assign
<T
, N
>(bv
);
288 template <typename T
, size_t N
>
289 void test_iterators_nd()
291 static_vector
<T
, N
> s
;
294 for ( size_t i
= 0 ; i
< N
; ++i
)
300 test_compare_ranges(s
.begin(), s
.end(), v
.begin(), v
.end());
301 test_compare_ranges(s
.rbegin(), s
.rend(), v
.rbegin(), v
.rend());
303 s
.assign(v
.rbegin(), v
.rend());
305 test_compare_ranges(s
.begin(), s
.end(), v
.rbegin(), v
.rend());
306 test_compare_ranges(s
.rbegin(), s
.rend(), v
.begin(), v
.end());
309 template <typename T
, size_t N
>
312 static_vector
<T
, N
> s
;
313 typedef typename static_vector
<T
, N
>::iterator It
;
315 for ( size_t i
= 0 ; i
< N
; ++i
)
320 for ( size_t i
= 0 ; i
< N
; ++i
)
322 static_vector
<T
, N
> s1(s
);
323 It it
= s1
.erase(s1
.begin() + i
);
324 BOOST_TEST(s1
.begin() + i
== it
);
325 BOOST_TEST(s1
.size() == N
- 1);
326 for ( size_t j
= 0 ; j
< i
; ++j
)
327 BOOST_TEST(s1
[j
] == T(j
));
328 for ( size_t j
= i
+1 ; j
< N
; ++j
)
329 BOOST_TEST(s1
[j
-1] == T(j
));
332 // erase(first, last)
335 for ( size_t i
= 0 ; i
<= N
; ++i
)
337 static_vector
<T
, N
> s1(s
);
338 size_t removed
= i
+ n
< N
? n
: N
- i
;
339 It it
= s1
.erase(s1
.begin() + i
, s1
.begin() + i
+ removed
);
340 BOOST_TEST(s1
.begin() + i
== it
);
341 BOOST_TEST(s1
.size() == N
- removed
);
342 for ( size_t j
= 0 ; j
< i
; ++j
)
343 BOOST_TEST(s1
[j
] == T(j
));
344 for ( size_t j
= i
+n
; j
< N
; ++j
)
345 BOOST_TEST(s1
[j
-n
] == T(j
));
350 template <typename T
, size_t N
, typename SV
, typename C
>
351 void test_insert(SV
const& s
, C
const& c
)
354 size_t n
= size_t(h
/1.5f
);
356 for ( size_t i
= 0 ; i
<= h
; ++i
)
358 static_vector
<T
, N
> s1(s
);
360 typename
C::const_iterator it
= c
.begin();
361 boost::container::iterator_advance(it
, n
);
362 typename static_vector
<T
, N
>::iterator
363 it1
= s1
.insert(s1
.begin() + i
, c
.begin(), it
);
365 BOOST_TEST(s1
.begin() + i
== it1
);
366 BOOST_TEST(s1
.size() == h
+n
);
367 for ( size_t j
= 0 ; j
< i
; ++j
)
368 BOOST_TEST(s1
[j
] == T(j
));
369 for ( size_t j
= 0 ; j
< n
; ++j
)
370 BOOST_TEST(s1
[j
+i
] == T(100 + j
));
371 for ( size_t j
= 0 ; j
< h
-i
; ++j
)
372 BOOST_TEST(s1
[j
+i
+n
] == T(j
+i
));
376 template <typename T
, size_t N
>
377 void test_insert_nd(T
const& val
)
381 static_vector
<T
, N
> s
, ss
;
385 typedef typename static_vector
<T
, N
>::iterator It
;
387 for ( size_t i
= 0 ; i
< h
; ++i
)
390 ss
.push_back(T(100 + i
));
391 v
.push_back(T(100 + i
));
392 l
.push_back(T(100 + i
));
397 for ( size_t i
= 0 ; i
<= h
; ++i
)
399 static_vector
<T
, N
> s1(s
);
400 It it
= s1
.insert(s1
.begin() + i
, val
);
401 BOOST_TEST(s1
.begin() + i
== it
);
402 BOOST_TEST(s1
.size() == h
+1);
403 for ( size_t j
= 0 ; j
< i
; ++j
)
404 BOOST_TEST(s1
[j
] == T(j
));
405 BOOST_TEST(s1
[i
] == val
);
406 for ( size_t j
= 0 ; j
< h
-i
; ++j
)
407 BOOST_TEST(s1
[j
+i
+1] == T(j
+i
));
410 // insert(pos, n, val)
412 size_t n
= size_t(h
/1.5f
);
413 for ( size_t i
= 0 ; i
<= h
; ++i
)
415 static_vector
<T
, N
> s1(s
);
416 It it
= s1
.insert(s1
.begin() + i
, n
, val
);
417 BOOST_TEST(s1
.begin() + i
== it
);
418 BOOST_TEST(s1
.size() == h
+n
);
419 for ( size_t j
= 0 ; j
< i
; ++j
)
420 BOOST_TEST(s1
[j
] == T(j
));
421 for ( size_t j
= 0 ; j
< n
; ++j
)
422 BOOST_TEST(s1
[j
+i
] == val
);
423 for ( size_t j
= 0 ; j
< h
-i
; ++j
)
424 BOOST_TEST(s1
[j
+i
+n
] == T(j
+i
));
427 // insert(pos, first, last)
428 test_insert
<T
, N
>(s
, ss
);
429 test_insert
<T
, N
>(s
, v
);
430 test_insert
<T
, N
>(s
, l
);
432 stable_vector
<T
> bsv(ss
.begin(), ss
.end());
433 vector
<T
> bv(ss
.begin(), ss
.end());
434 test_insert
<T
, N
>(s
, bv
);
435 test_insert
<T
, N
>(s
, bsv
);
438 template <typename T
>
439 void test_capacity_0_nd()
441 static_vector
<T
, 10> v(5u, T(0));
443 static_vector
<T
, 0 > s
;
444 BOOST_TEST(s
.size() == 0);
445 BOOST_TEST(s
.capacity() == 0);
446 BOOST_TEST_THROWS(s
.at(0), std::out_of_range
);
447 BOOST_TEST_THROWS(s
.resize(5u, T(0)), std::bad_alloc
);
448 BOOST_TEST_THROWS(s
.push_back(T(0)), std::bad_alloc
);
449 BOOST_TEST_THROWS(s
.insert(s
.end(), T(0)), std::bad_alloc
);
450 BOOST_TEST_THROWS(s
.insert(s
.end(), 5u, T(0)), std::bad_alloc
);
451 BOOST_TEST_THROWS(s
.insert(s
.end(), v
.begin(), v
.end()), std::bad_alloc
);
452 BOOST_TEST_THROWS(s
.assign(v
.begin(), v
.end()), std::bad_alloc
);
453 BOOST_TEST_THROWS(s
.assign(5u, T(0)), std::bad_alloc
);
454 BOOST_TEST_THROWS(s
.assign(5u, T(0)), std::bad_alloc
);
455 typedef static_vector
<T
, 0> static_vector_0_t
;
456 BOOST_TEST_THROWS(static_vector_0_t
s2(v
.begin(), v
.end()), std::bad_alloc
);
457 BOOST_TEST_THROWS(static_vector_0_t
s1(5u, T(0)), std::bad_alloc
);
460 template <typename T
, size_t N
>
461 void test_exceptions_nd()
463 static_vector
<T
, N
> v(N
, T(0));
464 static_vector
<T
, N
/2> s(N
/2, T(0));
466 BOOST_TEST_THROWS(s
.resize(N
, T(0)), std::bad_alloc
);
467 BOOST_TEST_THROWS(s
.push_back(T(0)), std::bad_alloc
);
468 BOOST_TEST_THROWS(s
.insert(s
.end(), T(0)), std::bad_alloc
);
469 BOOST_TEST_THROWS(s
.insert(s
.end(), N
, T(0)), std::bad_alloc
);
470 BOOST_TEST_THROWS(s
.insert(s
.end(), v
.begin(), v
.end()), std::bad_alloc
);
471 BOOST_TEST_THROWS(s
.assign(v
.begin(), v
.end()), std::bad_alloc
);
472 BOOST_TEST_THROWS(s
.assign(N
, T(0)), std::bad_alloc
);
473 typedef static_vector
<T
, N
/2> static_vector_n_half_t
;
474 BOOST_TEST_THROWS(static_vector_n_half_t
s2(v
.begin(), v
.end()), std::bad_alloc
);
475 BOOST_TEST_THROWS(static_vector_n_half_t
s1(N
, T(0)), std::bad_alloc
);
478 template <typename T
, size_t N
>
479 void test_swap_and_move_nd()
482 static_vector
<T
, N
> v1
, v2
, v3
, v4
;
483 static_vector
<T
, N
> s1
, s2
;
484 static_vector
<T
, N
> s4
;
486 for (size_t i
= 0 ; i
< N
; ++i
)
493 for (size_t i
= 0 ; i
< N
/2 ; ++i
)
495 s1
.push_back(T(100 + i
));
496 s2
.push_back(T(100 + i
));
497 s4
.push_back(T(100 + i
));
501 s2
= boost::move(v2
);
502 static_vector
<T
, N
> s3(boost::move(v3
));
505 BOOST_TEST(v1
.size() == N
/2);
506 BOOST_TEST(s1
.size() == N
);
507 //iG moving does not imply emptying source
508 //BOOST_TEST(v2.size() == 0);
509 BOOST_TEST(s2
.size() == N
);
510 //iG moving does not imply emptying source
511 //BOOST_TEST(v3.size() == 0);
512 BOOST_TEST(s3
.size() == N
);
513 BOOST_TEST(v4
.size() == N
/2);
514 BOOST_TEST(s4
.size() == N
);
515 for (size_t i
= 0 ; i
< N
/2 ; ++i
)
517 BOOST_TEST(v1
[i
] == T(100 + i
));
518 BOOST_TEST(v4
[i
] == T(100 + i
));
520 for (size_t i
= 0 ; i
< N
; ++i
)
522 BOOST_TEST(s1
[i
] == T(i
));
523 BOOST_TEST(s2
[i
] == T(i
));
524 BOOST_TEST(s3
[i
] == T(i
));
525 BOOST_TEST(s4
[i
] == T(i
));
529 static_vector
<T
, N
> v1
, v2
, v3
;
530 static_vector
<T
, N
/2> s1
, s2
, s3
;
532 for (size_t i
= 0 ; i
< N
/2 ; ++i
)
538 for (size_t i
= 0 ; i
< N
/3 ; ++i
)
540 s1
.push_back(T(100 + i
));
541 s2
.push_back(T(100 + i
));
546 s2
= boost::move(v2
);
547 static_vector
<T
, N
/2> s4(boost::move(v3
));
549 BOOST_TEST(v1
.size() == N
/3);
550 BOOST_TEST(s1
.size() == N
/2);
551 //iG moving does not imply emptying source
552 //BOOST_TEST(v2.size() == 0);
553 BOOST_TEST(s2
.size() == N
/2);
554 BOOST_TEST(s3
.size() == N
/2);
555 //iG moving does not imply emptying source
556 //BOOST_TEST(v3.size() == 0);
557 BOOST_TEST(s4
.size() == N
/2);
558 for (size_t i
= 0 ; i
< N
/3 ; ++i
)
559 BOOST_TEST(v1
[i
] == T(100 + i
));
560 for (size_t i
= 0 ; i
< N
/2 ; ++i
)
562 BOOST_TEST(s1
[i
] == T(i
));
563 BOOST_TEST(s2
[i
] == T(i
));
564 BOOST_TEST(s3
[i
] == T(i
));
565 BOOST_TEST(s4
[i
] == T(i
));
569 typedef static_vector
<T
, N
/2> small_vector_t
;
570 static_vector
<T
, N
> v(N
, T(0));
571 small_vector_t
s(N
/2, T(1));
572 BOOST_TEST_THROWS(s
.swap(v
), std::bad_alloc
);
574 BOOST_TEST_THROWS(s
= boost::move(v
), std::bad_alloc
);
575 BOOST_TEST_THROWS(s
= v
, std::bad_alloc
);
577 BOOST_TEST_THROWS(small_vector_t
s2(boost::move(v
)), std::bad_alloc
);
581 template <typename T
, size_t N
>
582 void test_emplace_0p()
586 static_vector
<T
, N
> v
;
588 for (int i
= 0 ; i
< int(N
) ; ++i
)
590 BOOST_TEST(v
.size() == N
);
591 BOOST_TEST_THROWS(v
.emplace_back(), std::bad_alloc
);
595 template <typename T
, size_t N
>
596 void test_emplace_2p()
598 //emplace_back(pos, int, int)
600 static_vector
<T
, N
> v
;
602 for (int i
= 0 ; i
< int(N
) ; ++i
)
603 v
.emplace_back(i
, 100 + i
);
604 BOOST_TEST(v
.size() == N
);
605 BOOST_TEST_THROWS(v
.emplace_back(N
, 100 + N
), std::bad_alloc
);
606 BOOST_TEST(v
.size() == N
);
607 for (int i
= 0 ; i
< int(N
) ; ++i
)
608 BOOST_TEST(v
[i
] == T(i
, 100 + i
));
611 // emplace(pos, int, int)
613 typedef typename static_vector
<T
, N
>::iterator It
;
617 static_vector
<T
, N
> v
;
618 for ( int i
= 0 ; i
< h
; ++i
)
619 v
.emplace_back(i
, 100 + i
);
621 for ( int i
= 0 ; i
<= h
; ++i
)
623 static_vector
<T
, N
> vv(v
);
624 It it
= vv
.emplace(vv
.begin() + i
, i
+100, i
+200);
625 BOOST_TEST(vv
.begin() + i
== it
);
626 BOOST_TEST(vv
.size() == size_t(h
+1));
627 for ( int j
= 0 ; j
< i
; ++j
)
628 BOOST_TEST(vv
[j
] == T(j
, j
+100));
629 BOOST_TEST(vv
[i
] == T(i
+100, i
+200));
630 for ( int j
= 0 ; j
< h
-i
; ++j
)
631 BOOST_TEST(vv
[j
+i
+1] == T(j
+i
, j
+i
+100));
636 template <typename T
, size_t N
>
637 void test_sv_elem(T
const& t
)
639 typedef static_vector
<T
, N
> V
;
641 static_vector
<V
, N
> v
;
643 v
.push_back(V(N
/2, t
));
645 v
.push_back(boost::move(vvv
));
646 v
.insert(v
.begin(), V(N
/2, t
));
647 v
.insert(v
.end(), V(N
/2, t
));
648 v
.emplace_back(N
/2, t
);
651 bool default_init_test()//Test for default initialization
653 const std::size_t Capacity
= 100;
655 typedef static_vector
<int, Capacity
> di_vector_t
;
658 di_vector_t
v(Capacity
, default_init
);
664 for(std::size_t i
= 0; i
!= Capacity
; ++i
, ++p
){
665 *p
= static_cast<int>(i
);
668 //Destroy the vector, p still pointing to the storage
671 di_vector_t
&rv
= *::new(&v
)di_vector_t(Capacity
, default_init
);
672 di_vector_t::iterator it
= rv
.begin();
674 for(std::size_t i
= 0; i
!= Capacity
; ++i
, ++it
){
675 if(*it
!= static_cast<int>(i
))
685 for(std::size_t i
= 0; i
!= Capacity
; ++i
, ++p
){
686 *p
= static_cast<int>(i
+100);
689 v
.resize(Capacity
, default_init
);
691 di_vector_t::iterator it
= v
.begin();
692 for(std::size_t i
= 0; i
!= Capacity
; ++i
, ++it
){
693 if(*it
!= static_cast<int>(i
+100))
702 int main(int, char* [])
704 using boost::container::test::movable_and_copyable_int
;
705 using boost::container::test::produce_movable_and_copyable_int
;
706 BOOST_TEST(counting_value::count() == 0);
708 test_ctor_ndc
<int, 10>();
709 test_ctor_ndc
<value_ndc
, 10>();
710 test_ctor_ndc
<counting_value
, 10>();
711 BOOST_TEST(counting_value::count() == 0);
712 test_ctor_ndc
<shptr_value
, 10>();
713 test_ctor_ndc
<movable_and_copyable_int
, 10>();
715 test_ctor_nc
<int, 10>(5);
716 test_ctor_nc
<value_nc
, 10>(5);
717 test_ctor_nc
<counting_value
, 10>(5);
718 BOOST_TEST(counting_value::count() == 0);
719 test_ctor_nc
<shptr_value
, 10>(5);
720 test_ctor_nc
<movable_and_copyable_int
, 10>(5);
722 test_ctor_nd
<int, 10>(5, 1);
723 test_ctor_nd
<value_nd
, 10>(5, value_nd(1));
724 test_ctor_nd
<counting_value
, 10>(5, counting_value(1));
725 BOOST_TEST(counting_value::count() == 0);
726 test_ctor_nd
<shptr_value
, 10>(5, shptr_value(1));
727 test_ctor_nd
<movable_and_copyable_int
, 10>(5, produce_movable_and_copyable_int());
729 test_resize_nc
<int, 10>(5);
730 test_resize_nc
<value_nc
, 10>(5);
731 test_resize_nc
<counting_value
, 10>(5);
732 BOOST_TEST(counting_value::count() == 0);
733 test_resize_nc
<shptr_value
, 10>(5);
734 test_resize_nc
<movable_and_copyable_int
, 10>(5);
736 test_resize_nd
<int, 10>(5, 1);
737 test_resize_nd
<value_nd
, 10>(5, value_nd(1));
738 test_resize_nd
<counting_value
, 10>(5, counting_value(1));
739 BOOST_TEST(counting_value::count() == 0);
740 test_resize_nd
<shptr_value
, 10>(5, shptr_value(1));
741 test_resize_nd
<movable_and_copyable_int
, 10>(5, produce_movable_and_copyable_int());
743 test_push_back_nd
<int, 10>();
744 test_push_back_nd
<value_nd
, 10>();
745 test_push_back_nd
<counting_value
, 10>();
746 BOOST_TEST(counting_value::count() == 0);
747 test_push_back_nd
<shptr_value
, 10>();
748 test_push_back_nd
<movable_and_copyable_int
, 10>();
750 test_pop_back_nd
<int, 10>();
751 test_pop_back_nd
<value_nd
, 10>();
752 test_pop_back_nd
<counting_value
, 10>();
753 BOOST_TEST(counting_value::count() == 0);
754 test_pop_back_nd
<shptr_value
, 10>();
755 test_pop_back_nd
<movable_and_copyable_int
, 10>();
757 test_copy_and_assign_nd
<int, 10>(1);
758 test_copy_and_assign_nd
<value_nd
, 10>(value_nd(1));
759 test_copy_and_assign_nd
<counting_value
, 10>(counting_value(1));
760 BOOST_TEST(counting_value::count() == 0);
761 test_copy_and_assign_nd
<shptr_value
, 10>(shptr_value(1));
762 test_copy_and_assign_nd
<movable_and_copyable_int
, 10>(produce_movable_and_copyable_int());
764 test_iterators_nd
<int, 10>();
765 test_iterators_nd
<value_nd
, 10>();
766 test_iterators_nd
<counting_value
, 10>();
767 BOOST_TEST(counting_value::count() == 0);
768 test_iterators_nd
<shptr_value
, 10>();
769 test_iterators_nd
<movable_and_copyable_int
, 10>();
771 test_erase_nd
<int, 10>();
772 test_erase_nd
<value_nd
, 10>();
773 test_erase_nd
<counting_value
, 10>();
774 BOOST_TEST(counting_value::count() == 0);
775 test_erase_nd
<shptr_value
, 10>();
776 test_erase_nd
<movable_and_copyable_int
, 10>();
778 test_insert_nd
<int, 10>(50);
779 test_insert_nd
<value_nd
, 10>(value_nd(50));
780 test_insert_nd
<counting_value
, 10>(counting_value(50));
781 BOOST_TEST(counting_value::count() == 0);
782 test_insert_nd
<shptr_value
, 10>(shptr_value(50));
783 test_insert_nd
<movable_and_copyable_int
, 10>(produce_movable_and_copyable_int());
785 test_capacity_0_nd
<int>();
786 test_capacity_0_nd
<value_nd
>();
787 test_capacity_0_nd
<counting_value
>();
788 BOOST_TEST(counting_value::count() == 0);
789 test_capacity_0_nd
<shptr_value
>();
790 test_capacity_0_nd
<movable_and_copyable_int
>();
792 test_exceptions_nd
<int, 10>();
793 test_exceptions_nd
<value_nd
, 10>();
794 test_exceptions_nd
<counting_value
, 10>();
795 BOOST_TEST(counting_value::count() == 0);
796 test_exceptions_nd
<shptr_value
, 10>();
797 test_exceptions_nd
<movable_and_copyable_int
, 10>();
799 test_swap_and_move_nd
<int, 10>();
800 test_swap_and_move_nd
<value_nd
, 10>();
801 test_swap_and_move_nd
<counting_value
, 10>();
802 BOOST_TEST(counting_value::count() == 0);
803 test_swap_and_move_nd
<shptr_value
, 10>();
804 test_swap_and_move_nd
<movable_and_copyable_int
, 10>();
806 test_emplace_0p
<counting_value
, 10>();
807 BOOST_TEST(counting_value::count() == 0);
809 test_emplace_2p
<counting_value
, 10>();
810 BOOST_TEST(counting_value::count() == 0);
812 test_sv_elem
<int, 10>(50);
813 test_sv_elem
<value_nd
, 10>(value_nd(50));
814 test_sv_elem
<counting_value
, 10>(counting_value(50));
815 BOOST_TEST(counting_value::count() == 0);
816 test_sv_elem
<shptr_value
, 10>(shptr_value(50));
817 test_sv_elem
<movable_and_copyable_int
, 10>(movable_and_copyable_int(50));
819 BOOST_TEST(default_init_test() == true);
821 test_support_for_initializer_list();
823 ////////////////////////////////////
825 ////////////////////////////////////
827 typedef boost::container::static_vector
<int, 3> cont_int
;
828 cont_int a
; a
.push_back(0); a
.push_back(1); a
.push_back(2);
829 boost::intrusive::test::test_iterator_random
< cont_int
>(a
);
832 return boost::report_errors();
835 #include <boost/container/detail/config_end.hpp>