]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/23_containers/list/cons/2.h
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 23_containers / list / cons / 2.h
CommitLineData
f1717362 1// Copyright (C) 2001-2016 Free Software Foundation, Inc.
2b3fc9df 2//
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)
7// any later version.
8
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.
13
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/>.
17
18// 23.2.2.1 list constructors, copy, and assignment
19
20#include <testsuite_hooks.h>
21
22// A nontrivial type.
23template<typename T>
24 struct A { };
25
26// Another nontrivial type
27struct B { };
28
29// Fill constructor
30//
31// This test verifies the following.
32// 23.2.2.1 explicit list(size_type n, const T& v = T(), const a& = Allocator())
33// 23.2.2 const_iterator begin() const
34// 23.2.2 const_iterator end() const
35// 23.2.2 size_type size() const
36//
37template<typename _Tp>
38void
39cons021()
40{
41 bool test __attribute__((unused)) = true;
42 const std::size_t LIST_SIZE = 5;
43 const int INIT_VALUE = 7;
44 std::size_t count;
45
46 typedef _Tp list_type;
47 typedef typename list_type::const_iterator const_iterator;
48 const_iterator i;
49
50 // default value
51 list_type list0202(LIST_SIZE);
52 for (i = list0202.begin(), count = 0;
53 i != list0202.end();
54 ++i, ++count)
55 VERIFY(*i == 0);
56 VERIFY(count == LIST_SIZE);
57 VERIFY(list0202.size() == LIST_SIZE);
58
59 // explicit value
60 list_type list0203(LIST_SIZE, INIT_VALUE);
61 for (i = list0203.begin(), count = 0;
62 i != list0203.end();
63 ++i, ++count)
64 VERIFY(*i == INIT_VALUE);
65 VERIFY(count == LIST_SIZE);
66 VERIFY(list0203.size() == LIST_SIZE);
67}
68
69template<typename _Tp>
70void
71cons022()
72{
73 // nontrivial value_type
74 typedef _Tp list_type;
75 const std::size_t LIST_SIZE = 5;
76 list_type list0201(LIST_SIZE);
77}