| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
#include <testsuite_hooks.h> |
| 21 |
|
| 22 |
|
| 23 |
template<typename _Tp> |
| 24 |
void |
| 25 |
operations01() |
| 26 |
{ |
| 27 |
typedef _Tp list_type; |
| 28 |
typedef typename list_type::iterator iterator; |
| 29 |
|
| 30 |
const int K = 417; |
| 31 |
const int A[] = {1, 2, 3, 4, 5}; |
| 32 |
const int B[] = {K, K, K, K, K}; |
| 33 |
const std::size_t N = sizeof(A) / sizeof(int); |
| 34 |
const std::size_t M = sizeof(B) / sizeof(int); |
| 35 |
|
| 36 |
list_type list0101(A, A + N); |
| 37 |
list_type list0102(B, B + M); |
| 38 |
iterator p = list0101.begin(); |
| 39 |
|
| 40 |
VERIFY(list0101.size() == N); |
| 41 |
VERIFY(list0102.size() == M); |
| 42 |
|
| 43 |
++p; |
| 44 |
list0101.splice(p, list0102); |
| 45 |
VERIFY(list0101.size() == N + M); |
| 46 |
VERIFY(list0102.size() == 0); |
| 47 |
|
| 48 |
|
| 49 |
list0101.remove(K); |
| 50 |
VERIFY(list0101.size() == N); |
| 51 |
|
| 52 |
|
| 53 |
list0101.remove(1); |
| 54 |
VERIFY(list0101.size() == N - 1); |
| 55 |
|
| 56 |
|
| 57 |
list0101.remove(5); |
| 58 |
VERIFY(list0101.size() == N - 2); |
| 59 |
|
| 60 |
|
| 61 |
list0101.reverse(); |
| 62 |
p = list0101.begin(); |
| 63 |
VERIFY(*p == 4); ++p; |
| 64 |
VERIFY(*p == 3); ++p; |
| 65 |
VERIFY(*p == 2); ++p; |
| 66 |
VERIFY(p == list0101.end()); |
| 67 |
} |