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"
24 template <typename T
, size_t N
>
27 static_vector
<T
, N
> s
;
28 BOOST_STATIC_ASSERT((static_vector
<T
, N
>::static_capacity
) == N
);
29 BOOST_TEST_EQ(s
.size() , 0u);
30 BOOST_TEST(s
.capacity() == N
);
31 BOOST_TEST(s
.max_size() == N
);
32 BOOST_TEST_THROWS( s
.at(0u), std::out_of_range
);
35 template <typename T
, size_t N
>
36 void test_ctor_nc(size_t n
)
38 static_vector
<T
, N
> s(n
);
39 BOOST_STATIC_ASSERT((static_vector
<T
, N
>::static_capacity
) == N
);
40 BOOST_TEST(s
.size() == n
);
41 BOOST_TEST(s
.capacity() == N
);
42 BOOST_TEST(s
.max_size() == N
);
43 BOOST_TEST_THROWS( s
.at(n
), std::out_of_range
);
48 BOOST_TEST(T(10) == s
[0]);
49 BOOST_TEST(T(10) == s
.at(0));
52 BOOST_TEST(T(20) == s
[1]);
53 BOOST_TEST(T(20) == s
.at(1));
57 template <typename T
, size_t N
>
58 void test_ctor_nd(size_t n
, T
const& v
)
60 static_vector
<T
, N
> s(n
, v
);
61 BOOST_STATIC_ASSERT((static_vector
<T
, N
>::static_capacity
) == N
);
62 BOOST_TEST(s
.size() == n
);
63 BOOST_TEST(s
.capacity() == N
);
64 BOOST_TEST_THROWS( s
.at(n
), std::out_of_range
);
67 BOOST_TEST(v
== s
[0]);
68 BOOST_TEST(v
== s
.at(0));
69 BOOST_TEST(v
== s
[1]);
70 BOOST_TEST(v
== s
.at(1));
72 BOOST_TEST(T(10) == s
[0]);
73 BOOST_TEST(T(10) == s
.at(0));
75 BOOST_TEST(T(20) == s
[1]);
76 BOOST_TEST(T(20) == s
.at(1));
80 void test_support_for_initializer_list()
82 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
84 static_vector
<int, 2> sv
= {10, 8};
85 BOOST_TEST(10 == sv
[0]);
86 BOOST_TEST(8 == sv
[1]);
88 typedef static_vector
<int, 1> sv_cap_1
;
89 BOOST_TEST_THROWS(sv_cap_1({1, 1}), std::bad_alloc
);
93 static_vector
<int, 2> sv
;
95 BOOST_TEST(1 == sv
[0]);
96 BOOST_TEST(2 == sv
[1]);
98 BOOST_TEST_THROWS(sv
.assign({1, 2, 3}), std::bad_alloc
);
100 static_vector
<int, 3> greaterThanSv
= {1, 2, 3};
101 BOOST_TEST_THROWS(sv
= greaterThanSv
, std::bad_alloc
);
105 static_vector
<int, 2> sv
;
106 sv
.insert(sv
.begin(), {99, 95});
107 BOOST_TEST(99 == sv
[0]);
108 BOOST_TEST(95 == sv
[1]);
110 BOOST_TEST_THROWS(sv
.insert(sv
.begin(), {101, 102, 103}), std::bad_alloc
);
115 template <typename T
, size_t N
>
116 void test_resize_nc(size_t n
)
118 static_vector
<T
, N
> s
;
121 BOOST_TEST(s
.size() == n
);
122 BOOST_TEST(s
.capacity() == N
);
123 BOOST_TEST_THROWS( s
.at(n
), std::out_of_range
);
128 BOOST_TEST(T(10) == s
[0]);
129 BOOST_TEST(T(10) == s
.at(0));
132 BOOST_TEST(T(20) == s
[1]);
133 BOOST_TEST(T(20) == s
.at(1));
137 template <typename T
, size_t N
>
138 void test_resize_nd(size_t n
, T
const& v
)
140 static_vector
<T
, N
> s
;
143 BOOST_TEST(s
.size() == n
);
144 BOOST_TEST(s
.capacity() == N
);
145 BOOST_TEST_THROWS( s
.at(n
), std::out_of_range
);
148 BOOST_TEST(v
== s
[0]);
149 BOOST_TEST(v
== s
.at(0));
150 BOOST_TEST(v
== s
[1]);
151 BOOST_TEST(v
== s
.at(1));
153 BOOST_TEST(T(10) == s
[0]);
154 BOOST_TEST(T(10) == s
.at(0));
156 BOOST_TEST(T(20) == s
[1]);
157 BOOST_TEST(T(20) == s
.at(1));
161 template <typename T
, size_t N
>
162 void test_push_back_nd()
164 static_vector
<T
, N
> s
;
166 BOOST_TEST(s
.size() == 0);
167 BOOST_TEST_THROWS( s
.at(0), std::out_of_range
);
169 for ( size_t i
= 0 ; i
< N
; ++i
)
173 BOOST_TEST(s
.size() == i
+ 1);
174 BOOST_TEST_THROWS( s
.at(i
+ 1), std::out_of_range
);
175 BOOST_TEST(T(i
) == s
.at(i
));
176 BOOST_TEST(T(i
) == s
[i
]);
177 BOOST_TEST(T(i
) == s
.back());
178 BOOST_TEST(T(0) == s
.front());
179 BOOST_TEST(T(i
) == *(s
.data() + i
));
183 template <typename T
, size_t N
>
184 void test_pop_back_nd()
186 static_vector
<T
, N
> s
;
188 for ( size_t i
= 0 ; i
< N
; ++i
)
194 for ( size_t i
= N
; i
> 1 ; --i
)
197 BOOST_TEST(s
.size() == i
- 1);
198 BOOST_TEST_THROWS( s
.at(i
- 1), std::out_of_range
);
199 BOOST_TEST(T(i
- 2) == s
.at(i
- 2));
200 BOOST_TEST(T(i
- 2) == s
[i
- 2]);
201 BOOST_TEST(T(i
- 2) == s
.back());
202 BOOST_TEST(T(0) == s
.front());
206 template <typename It1
, typename It2
>
207 void test_compare_ranges(It1 first1
, It1 last1
, It2 first2
, It2 last2
)
209 BOOST_TEST(boost::container::iterator_distance(first1
, last1
) == boost::container::iterator_distance(first2
, last2
));
210 for ( ; first1
!= last1
&& first2
!= last2
; ++first1
, ++first2
)
211 BOOST_TEST(*first1
== *first2
);
214 template <typename T
, size_t N
, typename C
>
215 void test_copy_and_assign(C
const& c
)
218 static_vector
<T
, N
> s(c
.begin(), c
.end());
219 BOOST_TEST(s
.size() == c
.size());
220 test_compare_ranges(s
.begin(), s
.end(), c
.begin(), c
.end());
223 static_vector
<T
, N
> s
;
224 BOOST_TEST(0 == s
.size());
225 s
.assign(c
.begin(), c
.end());
226 BOOST_TEST(s
.size() == c
.size());
227 test_compare_ranges(s
.begin(), s
.end(), c
.begin(), c
.end());
231 template <typename T
, size_t N
>
232 void test_copy_and_assign_nd(T
const& val
)
234 static_vector
<T
, N
> s
;
238 for ( size_t i
= 0 ; i
< N
; ++i
)
247 static_vector
<T
, N
> s1(s
);
248 BOOST_TEST(s
.size() == s1
.size());
249 test_compare_ranges(s
.begin(), s
.end(), s1
.begin(), s1
.end());
253 static_vector
<T
, N
> s1
;
254 BOOST_TEST(0 == s1
.size());
256 BOOST_TEST(s
.size() == s1
.size());
257 test_compare_ranges(s
.begin(), s
.end(), s1
.begin(), s1
.end());
260 // ctor(Iter, Iter) and assign(Iter, Iter)
261 test_copy_and_assign
<T
, N
>(s
);
262 test_copy_and_assign
<T
, N
>(v
);
263 test_copy_and_assign
<T
, N
>(l
);
267 static_vector
<T
, N
> s1(s
);
268 test_compare_ranges(s
.begin(), s
.end(), s1
.begin(), s1
.end());
269 std::vector
<T
> a(N
, val
);
271 test_compare_ranges(a
.begin(), a
.end(), s1
.begin(), s1
.end());
274 stable_vector
<T
> bsv(s
.begin(), s
.end());
275 vector
<T
> bv(s
.begin(), s
.end());
276 test_copy_and_assign
<T
, N
>(bsv
);
277 test_copy_and_assign
<T
, N
>(bv
);
280 template <typename T
, size_t N
>
281 void test_iterators_nd()
283 static_vector
<T
, N
> s
;
286 for ( size_t i
= 0 ; i
< N
; ++i
)
292 test_compare_ranges(s
.begin(), s
.end(), v
.begin(), v
.end());
293 test_compare_ranges(s
.rbegin(), s
.rend(), v
.rbegin(), v
.rend());
295 s
.assign(v
.rbegin(), v
.rend());
297 test_compare_ranges(s
.begin(), s
.end(), v
.rbegin(), v
.rend());
298 test_compare_ranges(s
.rbegin(), s
.rend(), v
.begin(), v
.end());
301 template <typename T
, size_t N
>
304 static_vector
<T
, N
> s
;
305 typedef typename static_vector
<T
, N
>::iterator It
;
307 for ( size_t i
= 0 ; i
< N
; ++i
)
312 for ( size_t i
= 0 ; i
< N
; ++i
)
314 static_vector
<T
, N
> s1(s
);
315 It it
= s1
.erase(s1
.begin() + i
);
316 BOOST_TEST(s1
.begin() + i
== it
);
317 BOOST_TEST(s1
.size() == N
- 1);
318 for ( size_t j
= 0 ; j
< i
; ++j
)
319 BOOST_TEST(s1
[j
] == T(j
));
320 for ( size_t j
= i
+1 ; j
< N
; ++j
)
321 BOOST_TEST(s1
[j
-1] == T(j
));
324 // erase(first, last)
327 for ( size_t i
= 0 ; i
<= N
; ++i
)
329 static_vector
<T
, N
> s1(s
);
330 size_t removed
= i
+ n
< N
? n
: N
- i
;
331 It it
= s1
.erase(s1
.begin() + i
, s1
.begin() + i
+ removed
);
332 BOOST_TEST(s1
.begin() + i
== it
);
333 BOOST_TEST(s1
.size() == N
- removed
);
334 for ( size_t j
= 0 ; j
< i
; ++j
)
335 BOOST_TEST(s1
[j
] == T(j
));
336 for ( size_t j
= i
+n
; j
< N
; ++j
)
337 BOOST_TEST(s1
[j
-n
] == T(j
));
342 template <typename T
, size_t N
, typename SV
, typename C
>
343 void test_insert(SV
const& s
, C
const& c
)
346 size_t n
= size_t(h
/1.5f
);
348 for ( size_t i
= 0 ; i
<= h
; ++i
)
350 static_vector
<T
, N
> s1(s
);
352 typename
C::const_iterator it
= c
.begin();
353 boost::container::iterator_advance(it
, n
);
354 typename static_vector
<T
, N
>::iterator
355 it1
= s1
.insert(s1
.begin() + i
, c
.begin(), it
);
357 BOOST_TEST(s1
.begin() + i
== it1
);
358 BOOST_TEST(s1
.size() == h
+n
);
359 for ( size_t j
= 0 ; j
< i
; ++j
)
360 BOOST_TEST(s1
[j
] == T(j
));
361 for ( size_t j
= 0 ; j
< n
; ++j
)
362 BOOST_TEST(s1
[j
+i
] == T(100 + j
));
363 for ( size_t j
= 0 ; j
< h
-i
; ++j
)
364 BOOST_TEST(s1
[j
+i
+n
] == T(j
+i
));
368 template <typename T
, size_t N
>
369 void test_insert_nd(T
const& val
)
373 static_vector
<T
, N
> s
, ss
;
377 typedef typename static_vector
<T
, N
>::iterator It
;
379 for ( size_t i
= 0 ; i
< h
; ++i
)
382 ss
.push_back(T(100 + i
));
383 v
.push_back(T(100 + i
));
384 l
.push_back(T(100 + i
));
389 for ( size_t i
= 0 ; i
<= h
; ++i
)
391 static_vector
<T
, N
> s1(s
);
392 It it
= s1
.insert(s1
.begin() + i
, val
);
393 BOOST_TEST(s1
.begin() + i
== it
);
394 BOOST_TEST(s1
.size() == h
+1);
395 for ( size_t j
= 0 ; j
< i
; ++j
)
396 BOOST_TEST(s1
[j
] == T(j
));
397 BOOST_TEST(s1
[i
] == val
);
398 for ( size_t j
= 0 ; j
< h
-i
; ++j
)
399 BOOST_TEST(s1
[j
+i
+1] == T(j
+i
));
402 // insert(pos, n, val)
404 size_t n
= size_t(h
/1.5f
);
405 for ( size_t i
= 0 ; i
<= h
; ++i
)
407 static_vector
<T
, N
> s1(s
);
408 It it
= s1
.insert(s1
.begin() + i
, n
, val
);
409 BOOST_TEST(s1
.begin() + i
== it
);
410 BOOST_TEST(s1
.size() == h
+n
);
411 for ( size_t j
= 0 ; j
< i
; ++j
)
412 BOOST_TEST(s1
[j
] == T(j
));
413 for ( size_t j
= 0 ; j
< n
; ++j
)
414 BOOST_TEST(s1
[j
+i
] == val
);
415 for ( size_t j
= 0 ; j
< h
-i
; ++j
)
416 BOOST_TEST(s1
[j
+i
+n
] == T(j
+i
));
419 // insert(pos, first, last)
420 test_insert
<T
, N
>(s
, ss
);
421 test_insert
<T
, N
>(s
, v
);
422 test_insert
<T
, N
>(s
, l
);
424 stable_vector
<T
> bsv(ss
.begin(), ss
.end());
425 vector
<T
> bv(ss
.begin(), ss
.end());
426 test_insert
<T
, N
>(s
, bv
);
427 test_insert
<T
, N
>(s
, bsv
);
430 template <typename T
>
431 void test_capacity_0_nd()
433 static_vector
<T
, 10> v(5u, T(0));
435 static_vector
<T
, 0 > s
;
436 BOOST_TEST(s
.size() == 0);
437 BOOST_TEST(s
.capacity() == 0);
438 BOOST_TEST_THROWS(s
.at(0), std::out_of_range
);
439 BOOST_TEST_THROWS(s
.resize(5u, T(0)), std::bad_alloc
);
440 BOOST_TEST_THROWS(s
.push_back(T(0)), std::bad_alloc
);
441 BOOST_TEST_THROWS(s
.insert(s
.end(), T(0)), std::bad_alloc
);
442 BOOST_TEST_THROWS(s
.insert(s
.end(), 5u, T(0)), std::bad_alloc
);
443 BOOST_TEST_THROWS(s
.insert(s
.end(), v
.begin(), v
.end()), std::bad_alloc
);
444 BOOST_TEST_THROWS(s
.assign(v
.begin(), v
.end()), std::bad_alloc
);
445 BOOST_TEST_THROWS(s
.assign(5u, T(0)), std::bad_alloc
);
446 BOOST_TEST_THROWS(s
.assign(5u, T(0)), std::bad_alloc
);
447 typedef static_vector
<T
, 0> static_vector_0_t
;
448 BOOST_TEST_THROWS(static_vector_0_t
s2(v
.begin(), v
.end()), std::bad_alloc
);
449 BOOST_TEST_THROWS(static_vector_0_t
s1(5u, T(0)), std::bad_alloc
);
452 template <typename T
, size_t N
>
453 void test_exceptions_nd()
455 static_vector
<T
, N
> v(N
, T(0));
456 static_vector
<T
, N
/2> s(N
/2, T(0));
458 BOOST_TEST_THROWS(s
.resize(N
, T(0)), std::bad_alloc
);
459 BOOST_TEST_THROWS(s
.push_back(T(0)), std::bad_alloc
);
460 BOOST_TEST_THROWS(s
.insert(s
.end(), T(0)), std::bad_alloc
);
461 BOOST_TEST_THROWS(s
.insert(s
.end(), 1, T(0)), std::bad_alloc
);
462 BOOST_TEST_THROWS(s
.insert(s
.end(), v
.begin(), v
.end()), std::bad_alloc
);
463 BOOST_TEST_THROWS(s
.assign(v
.begin(), v
.end()), std::bad_alloc
);
464 BOOST_TEST_THROWS(s
.assign(N
, T(0)), std::bad_alloc
);
465 typedef static_vector
<T
, N
/2> static_vector_n_half_t
;
466 BOOST_TEST_THROWS(static_vector_n_half_t
s2(v
.begin(), v
.end()), std::bad_alloc
);
467 BOOST_TEST_THROWS(static_vector_n_half_t
s1(N
/2+1, T(0)), std::bad_alloc
);
470 template <typename T
, size_t N
>
471 void test_swap_and_move_nd()
474 static_vector
<T
, N
> v1
, v2
, v3
, v4
;
475 static_vector
<T
, N
> s1
, s2
;
476 static_vector
<T
, N
> s4
;
478 for (size_t i
= 0 ; i
< N
; ++i
)
485 for (size_t i
= 0 ; i
< N
/2 ; ++i
)
487 s1
.push_back(T(100 + i
));
488 s2
.push_back(T(100 + i
));
489 s4
.push_back(T(100 + i
));
493 s2
= boost::move(v2
);
494 static_vector
<T
, N
> s3(boost::move(v3
));
497 BOOST_TEST(v1
.size() == N
/2);
498 BOOST_TEST(s1
.size() == N
);
499 //iG moving does not imply emptying source
500 //BOOST_TEST(v2.size() == 0);
501 BOOST_TEST(s2
.size() == N
);
502 //iG moving does not imply emptying source
503 //BOOST_TEST(v3.size() == 0);
504 BOOST_TEST(s3
.size() == N
);
505 BOOST_TEST(v4
.size() == N
/2);
506 BOOST_TEST(s4
.size() == N
);
507 for (size_t i
= 0 ; i
< N
/2 ; ++i
)
509 BOOST_TEST(v1
[i
] == T(100 + i
));
510 BOOST_TEST(v4
[i
] == T(100 + i
));
512 for (size_t i
= 0 ; i
< N
; ++i
)
514 BOOST_TEST(s1
[i
] == T(i
));
515 BOOST_TEST(s2
[i
] == T(i
));
516 BOOST_TEST(s3
[i
] == T(i
));
517 BOOST_TEST(s4
[i
] == T(i
));
521 static_vector
<T
, N
> v1
, v2
, v3
;
522 static_vector
<T
, N
/2> s1
, s2
, s3
;
524 for (size_t i
= 0 ; i
< N
/2 ; ++i
)
530 for (size_t i
= 0 ; i
< N
/3 ; ++i
)
532 s1
.push_back(T(100 + i
));
533 s2
.push_back(T(100 + i
));
538 s2
= boost::move(v2
);
539 static_vector
<T
, N
/2> s4(boost::move(v3
));
541 BOOST_TEST(v1
.size() == N
/3);
542 BOOST_TEST(s1
.size() == N
/2);
543 //iG moving does not imply emptying source
544 //BOOST_TEST(v2.size() == 0);
545 BOOST_TEST(s2
.size() == N
/2);
546 BOOST_TEST(s3
.size() == N
/2);
547 //iG moving does not imply emptying source
548 //BOOST_TEST(v3.size() == 0);
549 BOOST_TEST(s4
.size() == N
/2);
550 for (size_t i
= 0 ; i
< N
/3 ; ++i
)
551 BOOST_TEST(v1
[i
] == T(100 + i
));
552 for (size_t i
= 0 ; i
< N
/2 ; ++i
)
554 BOOST_TEST(s1
[i
] == T(i
));
555 BOOST_TEST(s2
[i
] == T(i
));
556 BOOST_TEST(s3
[i
] == T(i
));
557 BOOST_TEST(s4
[i
] == T(i
));
561 typedef static_vector
<T
, N
/2> small_vector_t
;
562 static_vector
<T
, N
> v(N
, T(0));
563 small_vector_t
s(N
/2, T(1));
564 BOOST_TEST_THROWS(s
.swap(v
), std::bad_alloc
);
566 BOOST_TEST_THROWS(s
= boost::move(v
), std::bad_alloc
);
567 BOOST_TEST_THROWS(s
= v
, std::bad_alloc
);
569 BOOST_TEST_THROWS(small_vector_t
s2(boost::move(v
)), std::bad_alloc
);
573 template <typename T
, size_t N
>
574 void test_emplace_0p()
578 static_vector
<T
, N
> v
;
580 for (int i
= 0 ; i
< int(N
) ; ++i
)
582 BOOST_TEST(v
.size() == N
);
583 BOOST_TEST_THROWS(v
.emplace_back(), std::bad_alloc
);
587 template <typename T
, size_t N
>
588 void test_emplace_2p()
590 //emplace_back(pos, int, int)
592 static_vector
<T
, N
> v
;
594 for (int i
= 0 ; i
< int(N
) ; ++i
)
595 v
.emplace_back(i
, 100 + i
);
596 BOOST_TEST(v
.size() == N
);
597 BOOST_TEST_THROWS(v
.emplace_back(N
, 100 + N
), std::bad_alloc
);
598 BOOST_TEST(v
.size() == N
);
599 for (int i
= 0 ; i
< int(N
) ; ++i
)
600 BOOST_TEST(v
[i
] == T(i
, 100 + i
));
603 // emplace(pos, int, int)
605 typedef typename static_vector
<T
, N
>::iterator It
;
609 static_vector
<T
, N
> v
;
610 for ( int i
= 0 ; i
< h
; ++i
)
611 v
.emplace_back(i
, 100 + i
);
613 for ( int i
= 0 ; i
<= h
; ++i
)
615 static_vector
<T
, N
> vv(v
);
616 It it
= vv
.emplace(vv
.begin() + i
, i
+100, i
+200);
617 BOOST_TEST(vv
.begin() + i
== it
);
618 BOOST_TEST(vv
.size() == size_t(h
+1));
619 for ( int j
= 0 ; j
< i
; ++j
)
620 BOOST_TEST(vv
[j
] == T(j
, j
+100));
621 BOOST_TEST(vv
[i
] == T(i
+100, i
+200));
622 for ( int j
= 0 ; j
< h
-i
; ++j
)
623 BOOST_TEST(vv
[j
+i
+1] == T(j
+i
, j
+i
+100));
628 template <typename T
, size_t N
>
629 void test_sv_elem(T
const& t
)
631 typedef static_vector
<T
, N
> V
;
633 static_vector
<V
, N
> v
;
635 v
.push_back(V(N
/2, t
));
637 v
.push_back(boost::move(vvv
));
638 v
.insert(v
.begin(), V(N
/2, t
));
639 v
.insert(v
.end(), V(N
/2, t
));
640 v
.emplace_back(N
/2, t
);
643 bool default_init_test()//Test for default initialization
645 const std::size_t Capacity
= 100;
647 typedef static_vector
<int, Capacity
> di_vector_t
;
650 di_vector_t
v(Capacity
, default_init
);
656 for(std::size_t i
= 0; i
!= Capacity
; ++i
, ++p
){
657 *p
= static_cast<int>(i
);
660 //Destroy the vector, p still pointing to the storage
663 di_vector_t
&rv
= *::new(&v
)di_vector_t(Capacity
, default_init
);
664 di_vector_t::iterator it
= rv
.begin();
666 for(std::size_t i
= 0; i
!= Capacity
; ++i
, ++it
){
667 if(*it
!= static_cast<int>(i
))
677 for(std::size_t i
= 0; i
!= Capacity
; ++i
, ++p
){
678 *p
= static_cast<int>(i
+100);
681 v
.resize(Capacity
, default_init
);
683 di_vector_t::iterator it
= v
.begin();
684 for(std::size_t i
= 0; i
!= Capacity
; ++i
, ++it
){
685 if(*it
!= static_cast<int>(i
+100))
694 int main(int, char* [])
696 using boost::container::test::movable_and_copyable_int
;
697 using boost::container::test::produce_movable_and_copyable_int
;
698 BOOST_TEST(counting_value::count() == 0);
700 test_ctor_ndc
<int, 10>();
701 test_ctor_ndc
<value_ndc
, 10>();
702 test_ctor_ndc
<counting_value
, 10>();
703 BOOST_TEST(counting_value::count() == 0);
704 test_ctor_ndc
<shptr_value
, 10>();
705 test_ctor_ndc
<movable_and_copyable_int
, 10>();
707 test_ctor_nc
<int, 10>(5);
708 test_ctor_nc
<value_nc
, 10>(5);
709 test_ctor_nc
<counting_value
, 10>(5);
710 BOOST_TEST(counting_value::count() == 0);
711 test_ctor_nc
<shptr_value
, 10>(5);
712 test_ctor_nc
<movable_and_copyable_int
, 10>(5);
714 test_ctor_nd
<int, 10>(5, 1);
715 test_ctor_nd
<value_nd
, 10>(5, value_nd(1));
716 test_ctor_nd
<counting_value
, 10>(5, counting_value(1));
717 BOOST_TEST(counting_value::count() == 0);
718 test_ctor_nd
<shptr_value
, 10>(5, shptr_value(1));
719 test_ctor_nd
<movable_and_copyable_int
, 10>(5, produce_movable_and_copyable_int());
721 test_resize_nc
<int, 10>(5);
722 test_resize_nc
<value_nc
, 10>(5);
723 test_resize_nc
<counting_value
, 10>(5);
724 BOOST_TEST(counting_value::count() == 0);
725 test_resize_nc
<shptr_value
, 10>(5);
726 test_resize_nc
<movable_and_copyable_int
, 10>(5);
728 test_resize_nd
<int, 10>(5, 1);
729 test_resize_nd
<value_nd
, 10>(5, value_nd(1));
730 test_resize_nd
<counting_value
, 10>(5, counting_value(1));
731 BOOST_TEST(counting_value::count() == 0);
732 test_resize_nd
<shptr_value
, 10>(5, shptr_value(1));
733 test_resize_nd
<movable_and_copyable_int
, 10>(5, produce_movable_and_copyable_int());
735 test_push_back_nd
<int, 10>();
736 test_push_back_nd
<value_nd
, 10>();
737 test_push_back_nd
<counting_value
, 10>();
738 BOOST_TEST(counting_value::count() == 0);
739 test_push_back_nd
<shptr_value
, 10>();
740 test_push_back_nd
<movable_and_copyable_int
, 10>();
742 test_pop_back_nd
<int, 10>();
743 test_pop_back_nd
<value_nd
, 10>();
744 test_pop_back_nd
<counting_value
, 10>();
745 BOOST_TEST(counting_value::count() == 0);
746 test_pop_back_nd
<shptr_value
, 10>();
747 test_pop_back_nd
<movable_and_copyable_int
, 10>();
749 test_copy_and_assign_nd
<int, 10>(1);
750 test_copy_and_assign_nd
<value_nd
, 10>(value_nd(1));
751 test_copy_and_assign_nd
<counting_value
, 10>(counting_value(1));
752 BOOST_TEST(counting_value::count() == 0);
753 test_copy_and_assign_nd
<shptr_value
, 10>(shptr_value(1));
754 test_copy_and_assign_nd
<movable_and_copyable_int
, 10>(produce_movable_and_copyable_int());
756 test_iterators_nd
<int, 10>();
757 test_iterators_nd
<value_nd
, 10>();
758 test_iterators_nd
<counting_value
, 10>();
759 BOOST_TEST(counting_value::count() == 0);
760 test_iterators_nd
<shptr_value
, 10>();
761 test_iterators_nd
<movable_and_copyable_int
, 10>();
763 test_erase_nd
<int, 10>();
764 test_erase_nd
<value_nd
, 10>();
765 test_erase_nd
<counting_value
, 10>();
766 BOOST_TEST(counting_value::count() == 0);
767 test_erase_nd
<shptr_value
, 10>();
768 test_erase_nd
<movable_and_copyable_int
, 10>();
770 test_insert_nd
<int, 10>(50);
771 test_insert_nd
<value_nd
, 10>(value_nd(50));
772 test_insert_nd
<counting_value
, 10>(counting_value(50));
773 BOOST_TEST(counting_value::count() == 0);
774 test_insert_nd
<shptr_value
, 10>(shptr_value(50));
775 test_insert_nd
<movable_and_copyable_int
, 10>(produce_movable_and_copyable_int());
777 test_capacity_0_nd
<int>();
778 test_capacity_0_nd
<value_nd
>();
779 test_capacity_0_nd
<counting_value
>();
780 BOOST_TEST(counting_value::count() == 0);
781 test_capacity_0_nd
<shptr_value
>();
782 test_capacity_0_nd
<movable_and_copyable_int
>();
784 test_exceptions_nd
<int, 10>();
785 test_exceptions_nd
<value_nd
, 10>();
786 test_exceptions_nd
<counting_value
, 10>();
787 BOOST_TEST(counting_value::count() == 0);
788 test_exceptions_nd
<shptr_value
, 10>();
789 test_exceptions_nd
<movable_and_copyable_int
, 10>();
791 test_swap_and_move_nd
<int, 10>();
792 test_swap_and_move_nd
<value_nd
, 10>();
793 test_swap_and_move_nd
<counting_value
, 10>();
794 BOOST_TEST(counting_value::count() == 0);
795 test_swap_and_move_nd
<shptr_value
, 10>();
796 test_swap_and_move_nd
<movable_and_copyable_int
, 10>();
798 test_emplace_0p
<counting_value
, 10>();
799 BOOST_TEST(counting_value::count() == 0);
801 test_emplace_2p
<counting_value
, 10>();
802 BOOST_TEST(counting_value::count() == 0);
804 test_sv_elem
<int, 10>(50);
805 test_sv_elem
<value_nd
, 10>(value_nd(50));
806 test_sv_elem
<counting_value
, 10>(counting_value(50));
807 BOOST_TEST(counting_value::count() == 0);
808 test_sv_elem
<shptr_value
, 10>(shptr_value(50));
809 test_sv_elem
<movable_and_copyable_int
, 10>(movable_and_copyable_int(50));
811 BOOST_TEST(default_init_test() == true);
813 test_support_for_initializer_list();
815 ////////////////////////////////////
817 ////////////////////////////////////
819 typedef boost::container::static_vector
<int, 3> cont_int
;
820 cont_int a
; a
.push_back(0); a
.push_back(1); a
.push_back(2);
821 boost::intrusive::test::test_iterator_random
< cont_int
>(a
);
824 return boost::report_errors();
827 #include <boost/container/detail/config_end.hpp>