1 // 2004-07-26 Matt Austern <austern@apple.com>
3 // Copyright (C) 2003, 2009 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/>.
23 #include <testsuite_allocator.h>
26 template<typename _Tp>
30 typedef _Tp list_type;
31 typedef typename list_type::iterator iterator_type;
33 using namespace __gnu_test;
34 const int arr10[10] = { 2, 4, 1, 7, 3, 8, 10, 5, 9, 6 };
37 tracker_allocator_counter::reset();
40 ok = check_construct_destroy("empty container", 0, 0) && ok;
42 ok = check_construct_destroy("empty container", 0, 0) && ok;
45 tracker_allocator_counter::reset();
47 list_type c(arr10, arr10 + 10);
48 ok = check_construct_destroy("Construct from range", 10, 0) && ok;
50 ok = check_construct_destroy("Construct from range", 10, 10) && ok;
53 list_type c(arr10, arr10 + 10);
54 tracker_allocator_counter::reset();
55 c.insert(c.begin(), arr10[0]);
56 ok = check_construct_destroy("Insert element", 1, 0) && ok;
58 ok = check_construct_destroy("Insert element", 1, 11) && ok;
61 list_type c(arr10, arr10 + 10);
62 tracker_allocator_counter::reset();
63 iterator_type i5 = c.begin();
65 c.insert(i5, arr10, arr10+3);
66 ok = check_construct_destroy("Insert short range", 3, 0) && ok;
68 ok = check_construct_destroy("Insert short range", 3, 13) && ok;
71 list_type c(arr10, arr10 + 10);
72 tracker_allocator_counter::reset();
73 iterator_type i7 = c.begin();
75 c.insert(i7, arr10, arr10+10);
76 ok = check_construct_destroy("Insert long range", 10, 0) && ok;
78 ok = check_construct_destroy("Insert long range", 10, 20) && ok;
85 construct_destroy<std::list<int, __gnu_test::tracker_allocator<int> > >();