]>
Commit | Line | Data |
---|---|---|
b74318f1 BW |
1 | |
2 | // Copyright (C) 2008 | |
3 | // Free Software Foundation, Inc. | |
4 | // | |
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 2, or (at your option) | |
9 | // any later version. | |
10 | ||
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. | |
15 | ||
16 | // You should have received a copy of the GNU General Public License along | |
17 | // with this library; see the file COPYING. If not, write to the Free | |
18 | // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | |
19 | // USA. | |
20 | ||
21 | // As a special exception, you may use this file as part of a free software | |
22 | // library without restriction. Specifically, if other files instantiate | |
23 | // templates or use macros or inline functions from this file, or you compile | |
24 | // this file and link it with other files to produce an executable, this | |
25 | // file does not by itself cause the resulting executable to be covered by | |
26 | // the GNU General Public License. This exception does not however | |
27 | // invalidate any other reasons why the executable file might be covered by | |
28 | // the GNU General Public License. | |
29 | ||
30 | #include <vector> | |
31 | #include <stdexcept> | |
32 | #include <testsuite_allocator.h> | |
33 | #include <testsuite_hooks.h> | |
34 | #include <ext/extptr_allocator.h> | |
35 | ||
36 | ||
37 | void test01() | |
38 | { | |
39 | // non POD types | |
40 | bool test __attribute__((unused)) = true; | |
41 | ||
42 | std::vector<int, __gnu_cxx::_ExtPtr_allocator<int> > vec01; | |
43 | typedef std::vector<int, __gnu_cxx::_ExtPtr_allocator<int> >::size_type size_type; | |
44 | ||
45 | VERIFY(vec01.empty()); | |
46 | ||
47 | const int A[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; | |
48 | ||
49 | // Test resize of the vector based on reserve | |
50 | size_type sz01 = vec01.capacity(); | |
51 | vec01.reserve(100); | |
52 | size_type sz02 = vec01.capacity(); | |
53 | VERIFY(sz02 >= sz01); | |
54 | ||
55 | // grow/shrink | |
56 | vec01.assign( A, A+10 ); | |
57 | sz01 = vec01.size() + 100; | |
58 | vec01.resize(sz01); | |
59 | sz02 = vec01.size(); | |
60 | VERIFY(sz01 == sz02); | |
61 | VERIFY(std::equal(vec01.begin(), vec01.begin()+10, A)); | |
62 | ||
63 | sz01 = vec01.size() - 100; | |
64 | vec01.resize(sz01); | |
65 | sz02 = vec01.size(); | |
66 | VERIFY(sz01 == sz02); | |
67 | VERIFY(std::equal(vec01.begin(), vec01.end(), A)); | |
68 | } | |
69 | ||
70 | int main() | |
71 | { | |
72 | test01(); | |
73 | return 0; | |
74 | } |