]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/23_containers/list/cons/7.cc
Licensing changes to GPLv3 resp. GPLv3 with GCC Runtime Exception.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 23_containers / list / cons / 7.cc
CommitLineData
748086b7 1// Copyright (C) 2001, 2004, 2005, 2009 Free Software Foundation, Inc.
17472bb6
BK
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
748086b7 6// Free Software Foundation; either version 3, or (at your option)
17472bb6
BK
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
748086b7
JJ
15// with this library; see the file COPYING3. If not see
16// <http://www.gnu.org/licenses/>.
17472bb6
BK
17
18// 23.2.2.1 list constructors, copy, and assignment
19
20#include <list>
21#include <testsuite_hooks.h>
22
11f10e6b 23bool test __attribute__((unused)) = true;
17472bb6
BK
24
25// Fill assign
26//
27// This test verifies the following.
28// 23.2.2.1 void assign(size_type n, const T& v)
29// 23.2.2 const_iterator begin() const
30// 23.2.2 const_iterator end() const
31// 23.2.2 size_type size() const
32//
33void
34test06()
35{
11f10e6b 36 const std::size_t BIG_LIST_SIZE = 11;
17472bb6 37 const int BIG_INIT_VALUE = 7;
11f10e6b 38 const std::size_t SMALL_LIST_SIZE = 5;
17472bb6 39 const int SMALL_INIT_VALUE = 17;
11f10e6b 40 std::size_t count;
17472bb6
BK
41 std::list<int>::const_iterator i;
42
43 std::list<int> list0601;
44 VERIFY(list0601.size() == 0);
45
46 // make it bigger
47 list0601.assign(BIG_LIST_SIZE, BIG_INIT_VALUE);
48 for (i = list0601.begin(), count = 0;
49 i != list0601.end();
50 ++i, ++count)
51 VERIFY(*i == BIG_INIT_VALUE);
52 VERIFY(count == BIG_LIST_SIZE);
53 VERIFY(list0601.size() == BIG_LIST_SIZE);
54
55 // make it shrink
56 list0601.assign(SMALL_LIST_SIZE, SMALL_INIT_VALUE);
57 for (i = list0601.begin(), count = 0;
58 i != list0601.end();
59 ++i, ++count)
60 VERIFY(*i == SMALL_INIT_VALUE);
61 VERIFY(count == SMALL_LIST_SIZE);
62 VERIFY(list0601.size() == SMALL_LIST_SIZE);
63}
64
65int main()
66{
67 test06();
68 return 0;
69}
f90e600a 70