1 2// Copyright (C) 2008, 2009 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 3, 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 COPYING3. If not see 18// <http://www.gnu.org/licenses/>. 19 20 21#include <vector> 22#include <stdexcept> 23#include <testsuite_allocator.h> 24#include <testsuite_hooks.h> 25#include <ext/extptr_allocator.h> 26 27 28void test01() 29{ 30 // non POD types 31 bool test __attribute__((unused)) = true; 32 33 std::vector<int, __gnu_cxx::_ExtPtr_allocator<int> > vec01; 34 typedef std::vector<int, __gnu_cxx::_ExtPtr_allocator<int> >::size_type size_type; 35 36 VERIFY(vec01.empty()); 37 38 const int A[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; 39 40 // Test resize of the vector based on reserve 41 size_type sz01 = vec01.capacity(); 42 vec01.reserve(100); 43 size_type sz02 = vec01.capacity(); 44 VERIFY(sz02 >= sz01); 45 46 // grow/shrink 47 vec01.assign( A, A+10 ); 48 sz01 = vec01.size() + 100; 49 vec01.resize(sz01); 50 sz02 = vec01.size(); 51 VERIFY(sz01 == sz02); 52 VERIFY(std::equal(vec01.begin(), vec01.begin()+10, A)); 53 54 sz01 = vec01.size() - 100; 55 vec01.resize(sz01); 56 sz02 = vec01.size(); 57 VERIFY(sz01 == sz02); 58 VERIFY(std::equal(vec01.begin(), vec01.end(), A)); 59} 60 61int main() 62{ 63 test01(); 64 return 0; 65} 66