1 // 2005-11-25 Paolo Carlini <pcarlini@suse.de>
3 // Copyright (C) 2005 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING. If not, write to the Free
18 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
21 // 23.2.1.3 deque modifiers
24 #include <testsuite_hooks.h>
26 const int A
[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
27 const int A1
[] = {0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
28 const int A2
[] = {0, 2, 3, 4, 10, 11, 12, 13, 14, 15};
29 const int A3
[] = {0, 2, 3, 4, 10, 11};
30 const int A4
[] = {4, 10, 11};
31 const int A5
[] = {4, 10};
32 const int N
= sizeof(A
) / sizeof(int);
33 const int N1
= sizeof(A1
) / sizeof(int);
34 const int N2
= sizeof(A2
) / sizeof(int);
35 const int N3
= sizeof(A3
) / sizeof(int);
36 const int N4
= sizeof(A4
) / sizeof(int);
37 const int N5
= sizeof(A5
) / sizeof(int);
42 bool test
__attribute__((unused
)) = true;
44 typedef std::deque
<int> deque_type
;
45 typedef deque_type::iterator iterator_type
;
47 deque_type
v(A
, A
+ N
);
49 iterator_type it1
= v
.erase(v
.begin() + 1);
50 VERIFY( it1
== v
.begin() + 1 );
51 VERIFY( v
.size() == N1
);
52 VERIFY( std::equal(v
.begin(), v
.end(), A1
) );
54 iterator_type it2
= v
.erase(v
.begin() + 4, v
.begin() + 9);
55 VERIFY( it2
== v
.begin() + 4 );
56 VERIFY( v
.size() == N2
);
57 VERIFY( std::equal(v
.begin(), v
.end(), A2
) );
59 iterator_type it3
= v
.erase(v
.begin() + 6, v
.end());
60 VERIFY( it3
== v
.begin() + 6 );
61 VERIFY( v
.size() == N3
);
62 VERIFY( std::equal(v
.begin(), v
.end(), A3
) );
64 iterator_type it4
= v
.erase(v
.begin(), v
.begin() + 3);
65 VERIFY( it4
== v
.begin() );
66 VERIFY( v
.size() == N4
);
67 VERIFY( std::equal(v
.begin(), v
.end(), A4
) );
69 iterator_type it5
= v
.erase(v
.begin() + 2);
70 VERIFY( it5
== v
.begin() + 2 );
71 VERIFY( v
.size() == N5
);
72 VERIFY( std::equal(v
.begin(), v
.end(), A5
) );
74 iterator_type it6
= v
.erase(v
.begin(), v
.end());
75 VERIFY( it6
== v
.begin() );
82 bool test
__attribute__((unused
)) = true;
84 typedef std::deque
<std::deque
<int> > deque_type
;
85 typedef deque_type::iterator iterator_type
;
87 deque_type v
, v1
, v2
, v3
, v4
, v5
;
88 for (int i
= 0; i
< N
; ++i
)
89 v
.push_back(std::deque
<int>(1, A
[i
]));
90 for (int i
= 0; i
< N1
; ++i
)
91 v1
.push_back(std::deque
<int>(1, A1
[i
]));
92 for (int i
= 0; i
< N2
; ++i
)
93 v2
.push_back(std::deque
<int>(1, A2
[i
]));
94 for (int i
= 0; i
< N3
; ++i
)
95 v3
.push_back(std::deque
<int>(1, A3
[i
]));
96 for (int i
= 0; i
< N4
; ++i
)
97 v4
.push_back(std::deque
<int>(1, A4
[i
]));
98 for (int i
= 0; i
< N5
; ++i
)
99 v5
.push_back(std::deque
<int>(1, A5
[i
]));
101 iterator_type it1
= v
.erase(v
.begin() + 1);
102 VERIFY( it1
== v
.begin() + 1 );
103 VERIFY( v
.size() == N1
);
104 VERIFY( std::equal(v
.begin(), v
.end(), v1
.begin()) );
106 iterator_type it2
= v
.erase(v
.begin() + 4, v
.begin() + 9);
107 VERIFY( it2
== v
.begin() + 4 );
108 VERIFY( v
.size() == N2
);
109 VERIFY( std::equal(v
.begin(), v
.end(), v2
.begin()) );
111 iterator_type it3
= v
.erase(v
.begin() + 6, v
.end());
112 VERIFY( it3
== v
.begin() + 6 );
113 VERIFY( v
.size() == N3
);
114 VERIFY( std::equal(v
.begin(), v
.end(), v3
.begin()) );
116 iterator_type it4
= v
.erase(v
.begin(), v
.begin() + 3);
117 VERIFY( it4
== v
.begin() );
118 VERIFY( v
.size() == N4
);
119 VERIFY( std::equal(v
.begin(), v
.end(), v4
.begin()) );
121 iterator_type it5
= v
.erase(v
.begin() + 2);
122 VERIFY( it5
== v
.begin() + 2 );
123 VERIFY( v
.size() == N5
);
124 VERIFY( std::equal(v
.begin(), v
.end(), v5
.begin()) );
126 iterator_type it6
= v
.erase(v
.begin(), v
.end());
127 VERIFY( it6
== v
.begin() );