1 // Copyright (C) 2005 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 2, or (at your option)
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without Pred 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 COPYING. If not, write to the Free
16 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
19 // 23.2.2.3 list modifiers [lib.list.modifiers]
22 #include <testsuite_hooks.h>
23 #include <testsuite_allocator.h>
28 bool test __attribute__((unused)) = true;
30 typedef __gnu_test::throw_allocator<int> my_alloc;
31 typedef std::list<int, my_alloc > my_list;
33 for (int j = 0; j < 10; ++j)
34 for (int i = 0; i < 10; ++i)
36 my_alloc alloc1(j + i);
37 my_list list1(alloc1);
39 for (int k = 0; k < j; ++k)
40 list1.push_back(-(k + 1));
44 list1.insert(list1.begin(), 10, 99);
47 catch (std::bad_alloc&)
56 VERIFY( list1.size() == my_list::size_type(j) );
57 VERIFY( list1.size() == 0 || list1.back() == -j );
58 VERIFY( list1.size() == 0 || list1.front() == -1 );
60 my_alloc alloc2(j + i);
61 my_list list2(alloc2);
63 const int data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
65 for (int k = 0; k < j; ++k)
66 list2.push_back(-(k + 1));
70 list2.insert(list2.begin(), data, data + 10);
73 catch (std::bad_alloc&)
82 VERIFY( list2.size() == my_list::size_type(j) );
83 VERIFY( list2.size() == 0 || list2.back() == -j );
84 VERIFY( list2.size() == 0 || list2.front() == -1 );