1//===----------------------------------------------------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is dual licensed under the MIT and the University of Illinois Open 6// Source Licenses. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10// <vector> 11 12// void resize(size_type sz, const value_type& x); 13 14#include <vector> 15#include <cassert> 16#include "../../../stack_allocator.h" 17#include "min_allocator.h" 18 19int main() 20{ 21 { 22 std::vector<int> v(100); 23 v.resize(50, 1); 24 assert(v.size() == 50); 25 assert(v.capacity() == 100); 26 assert(v == std::vector<int>(50)); 27 v.resize(200, 1); 28 assert(v.size() == 200); 29 assert(v.capacity() >= 200); 30 for (unsigned i = 0; i < 50; ++i) 31 assert(v[i] == 0); 32 for (unsigned i = 50; i < 200; ++i) 33 assert(v[i] == 1); 34 } 35 { 36 std::vector<int, stack_allocator<int, 300> > v(100); 37 v.resize(50, 1); 38 assert(v.size() == 50); 39 assert(v.capacity() == 100); 40 v.resize(200, 1); 41 assert(v.size() == 200); 42 assert(v.capacity() >= 200); 43 } 44#if __cplusplus >= 201103L 45 { 46 std::vector<int, min_allocator<int>> v(100); 47 v.resize(50, 1); 48 assert(v.size() == 50); 49 assert(v.capacity() == 100); 50 assert((v == std::vector<int, min_allocator<int>>(50))); 51 v.resize(200, 1); 52 assert(v.size() == 200); 53 assert(v.capacity() >= 200); 54 for (unsigned i = 0; i < 50; ++i) 55 assert(v[i] == 0); 56 for (unsigned i = 50; i < 200; ++i) 57 assert(v[i] == 1); 58 } 59 { 60 std::vector<int, min_allocator<int>> v(100); 61 v.resize(50, 1); 62 assert(v.size() == 50); 63 assert(v.capacity() == 100); 64 v.resize(200, 1); 65 assert(v.size() == 200); 66 assert(v.capacity() >= 200); 67 } 68#endif 69} 70