1 // Copyright (C) 2001-2019 Free Software Foundation, Inc.
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 3, or (at your option)
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
18 // 23.2.2.3 list modifiers [lib.list.modifiers]
20 #include <testsuite_hooks.h>
22 // This test verifies the following.
24 // 23.2.2.3 void push_front(const T& x)
25 // 23.2.2.3 void push_back(const T& x)
26 // 23.2.2.3 (1) iterator and reference non-invalidation
27 // 23.2.2.3 (1) exception effects
28 // 23.2.2.3 (2) complexity requirements
30 // 23.2.2.3 void pop_front()
31 // 23.2.2.3 void pop_back()
32 // 23.2.2.3 (3) iterator and reference non-invalidation
33 // 23.2.2.3 (5) complexity requirements
35 // 23.2.2 const_iterator begin() const
36 // 23.2.2 iterator end()
37 // 23.2.2 const_reverse_iterator rbegin() const
38 // 23.2.2 _reference front()
39 // 23.2.2 const_reference front() const
40 // 23.2.2 reference back()
41 // 23.2.2 const_reference back() const
43 template<typename _Tp
>
47 typedef _Tp list_type
;
48 typedef typename
list_type::iterator iterator
;
49 typedef typename
list_type::value_type value_type
;
50 typedef typename
list_type::const_iterator const_iterator
;
51 typedef typename
list_type::const_reverse_iterator const_reverse_iterator
;
53 using __gnu_test::copy_constructor
;
54 using __gnu_test::destructor
;
58 const_reverse_iterator j
;
62 list0101
.push_back(value_type(1)); // list should be [1]
63 VERIFY(list0101
.size() == 1);
64 VERIFY(copy_constructor::count() == 1);
69 VERIFY(k
->id() == list0101
.front().id());
70 VERIFY(k
->id() == list0101
.back().id());
72 list0101
.push_front(value_type(2)); // list should be [2 1]
73 VERIFY(list0101
.size() == 2);
74 VERIFY(copy_constructor::count() == 2);
77 list0101
.push_back(value_type(3)); // list should be [2 1 3]
78 VERIFY(list0101
.size() == 3);
79 VERIFY(copy_constructor::count() == 3);
84 list0101
.push_back(value_type(4, true));
89 VERIFY(list0101
.size() == 3);
90 VERIFY(copy_constructor::count() == 4);
95 VERIFY(i
->id() == list0101
.front().id());
97 j
= list0101
.rbegin();
99 VERIFY(j
->id() == list0101
.back().id());
102 VERIFY(i
->id() == 1);
105 VERIFY(j
->id() == 1);
109 list0101
.pop_back(); // list should be [2 1]
110 VERIFY(list0101
.size() == 2);
111 VERIFY(destructor::count() == 1);
112 VERIFY(i
->id() == 1);
113 VERIFY(k
->id() == 1);
115 list0101
.pop_front(); // list should be [1]
116 VERIFY(list0101
.size() == 1);
117 VERIFY(destructor::count() == 2);
118 VERIFY(i
->id() == 1);
119 VERIFY(k
->id() == 1);