1 // 2005-11-25 Paolo Carlini <pcarlini@suse.de>
3 // Copyright (C) 2005-2013 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 3, 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 COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
20 // 23.2.1.3 deque modifiers
23 #include <testsuite_hooks.h>
25 const int A[] = {-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
27 const int A0[] = {-5, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
28 const int A1[] = {-5, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
29 const int A2[] = {-5, 0, 1, 2, 8, 9, 10, 11, 12, 13, 14, 15};
30 const int A3[] = {-5, 0, 1, 2, 8, 9, 10, 11};
31 const int A4[] = {2, 8, 9, 10, 11};
32 const int A5[] = {2, 8, 10, 11};
33 const int A6[] = {2, 8, 10};
34 const unsigned N = sizeof(A) / sizeof(int);
35 const unsigned N0 = sizeof(A0) / sizeof(int);
36 const unsigned N1 = sizeof(A1) / sizeof(int);
37 const unsigned N2 = sizeof(A2) / sizeof(int);
38 const unsigned N3 = sizeof(A3) / sizeof(int);
39 const unsigned N4 = sizeof(A4) / sizeof(int);
40 const unsigned N5 = sizeof(A5) / sizeof(int);
41 const unsigned N6 = sizeof(A6) / sizeof(int);
61 bool test __attribute__((unused)) = true;
63 typedef std::deque<T> deque_type;
64 typedef typename deque_type::iterator iterator_type;
66 deque_type v(A, A + N);
68 iterator_type it0 = v.erase(v.begin() + 1, v.begin() + 4);
69 VERIFY( it0 == v.begin() + 1 );
70 VERIFY( v.size() == N0 );
71 VERIFY( std::equal(v.begin(), v.end(), A0) );
73 iterator_type it1 = v.erase(v.begin() + 1);
74 VERIFY( it1 == v.begin() + 1 );
75 VERIFY( v.size() == N1 );
76 VERIFY( std::equal(v.begin(), v.end(), A1) );
78 iterator_type it2 = v.erase(v.begin() + 4, v.begin() + 9);
79 VERIFY( it2 == v.begin() + 4 );
80 VERIFY( v.size() == N2 );
81 VERIFY( std::equal(v.begin(), v.end(), A2) );
83 iterator_type it3 = v.erase(v.begin() + 8, v.end());
84 VERIFY( it3 == v.begin() + 8 );
85 VERIFY( v.size() == N3 );
86 VERIFY( std::equal(v.begin(), v.end(), A3) );
88 iterator_type it4 = v.erase(v.begin(), v.begin() + 3);
89 VERIFY( it4 == v.begin() );
90 VERIFY( v.size() == N4 );
91 VERIFY( std::equal(v.begin(), v.end(), A4) );
93 iterator_type it5 = v.erase(v.begin() + 2);
94 VERIFY( it5 == v.begin() + 2 );
95 VERIFY( v.size() == N5 );
96 VERIFY( std::equal(v.begin(), v.end(), A5) );
98 iterator_type it6 = v.erase(v.begin() + 3, v.end());
99 VERIFY( it6 == v.begin() + 3 );
100 VERIFY( v.size() == N6 );
101 VERIFY( std::equal(v.begin(), v.end(), A6) );
103 iterator_type it7 = v.erase(v.begin(), v.end());
104 VERIFY( it7 == v.begin() );
110 test01<My_class<1> >();
111 test01<My_class<8> >();
112 test01<My_class<32> >();