]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/2.cc
1 // 2005-11-25 Paolo Carlini <pcarlini@suse.de>
3 // Copyright (C) 2005-2021 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 typedef std::deque
<T
> deque_type
;
62 typedef typename
deque_type::iterator iterator_type
;
64 deque_type
v(A
, A
+ N
);
66 iterator_type it0
= v
.erase(v
.begin() + 1, v
.begin() + 4);
67 VERIFY( it0
== v
.begin() + 1 );
68 VERIFY( v
.size() == N0
);
69 VERIFY( std::equal(v
.begin(), v
.end(), A0
) );
71 iterator_type it1
= v
.erase(v
.begin() + 1);
72 VERIFY( it1
== v
.begin() + 1 );
73 VERIFY( v
.size() == N1
);
74 VERIFY( std::equal(v
.begin(), v
.end(), A1
) );
76 iterator_type it2
= v
.erase(v
.begin() + 4, v
.begin() + 9);
77 VERIFY( it2
== v
.begin() + 4 );
78 VERIFY( v
.size() == N2
);
79 VERIFY( std::equal(v
.begin(), v
.end(), A2
) );
81 iterator_type it3
= v
.erase(v
.begin() + 8, v
.end());
82 VERIFY( it3
== v
.begin() + 8 );
83 VERIFY( v
.size() == N3
);
84 VERIFY( std::equal(v
.begin(), v
.end(), A3
) );
86 iterator_type it4
= v
.erase(v
.begin(), v
.begin() + 3);
87 VERIFY( it4
== v
.begin() );
88 VERIFY( v
.size() == N4
);
89 VERIFY( std::equal(v
.begin(), v
.end(), A4
) );
91 iterator_type it5
= v
.erase(v
.begin() + 2);
92 VERIFY( it5
== v
.begin() + 2 );
93 VERIFY( v
.size() == N5
);
94 VERIFY( std::equal(v
.begin(), v
.end(), A5
) );
96 iterator_type it6
= v
.erase(v
.begin() + 3, v
.end());
97 VERIFY( it6
== v
.begin() + 3 );
98 VERIFY( v
.size() == N6
);
99 VERIFY( std::equal(v
.begin(), v
.end(), A6
) );
101 iterator_type it7
= v
.erase(v
.begin(), v
.end());
102 VERIFY( it7
== v
.begin() );
108 test01
<My_class
<1> >();
109 test01
<My_class
<8> >();
110 test01
<My_class
<32> >();