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 push_back(const value_type& x); 13 14 #include <vector> 15 #include <cassert> 16 #include "../../../stack_allocator.h" 17 #include "min_allocator.h" 18 19 int main() 20 { 21 { 22 std::vector<int> c; 23 c.push_back(0); 24 assert(c.size() == 1); 25 for (int j = 0; j < c.size(); ++j) 26 assert(c[j] == j); 27 c.push_back(1); 28 assert(c.size() == 2); 29 for (int j = 0; j < c.size(); ++j) 30 assert(c[j] == j); 31 c.push_back(2); 32 assert(c.size() == 3); 33 for (int j = 0; j < c.size(); ++j) 34 assert(c[j] == j); 35 c.push_back(3); 36 assert(c.size() == 4); 37 for (int j = 0; j < c.size(); ++j) 38 assert(c[j] == j); 39 c.push_back(4); 40 assert(c.size() == 5); 41 for (int j = 0; j < c.size(); ++j) 42 assert(c[j] == j); 43 } 44 { 45 std::vector<int, stack_allocator<int, 15> > c; 46 c.push_back(0); 47 assert(c.size() == 1); 48 for (int j = 0; j < c.size(); ++j) 49 assert(c[j] == j); 50 c.push_back(1); 51 assert(c.size() == 2); 52 for (int j = 0; j < c.size(); ++j) 53 assert(c[j] == j); 54 c.push_back(2); 55 assert(c.size() == 3); 56 for (int j = 0; j < c.size(); ++j) 57 assert(c[j] == j); 58 c.push_back(3); 59 assert(c.size() == 4); 60 for (int j = 0; j < c.size(); ++j) 61 assert(c[j] == j); 62 c.push_back(4); 63 assert(c.size() == 5); 64 for (int j = 0; j < c.size(); ++j) 65 assert(c[j] == j); 66 } 67 #if __cplusplus >= 201103L 68 { 69 std::vector<int, min_allocator<int>> c; 70 c.push_back(0); 71 assert(c.size() == 1); 72 for (int j = 0; j < c.size(); ++j) 73 assert(c[j] == j); 74 c.push_back(1); 75 assert(c.size() == 2); 76 for (int j = 0; j < c.size(); ++j) 77 assert(c[j] == j); 78 c.push_back(2); 79 assert(c.size() == 3); 80 for (int j = 0; j < c.size(); ++j) 81 assert(c[j] == j); 82 c.push_back(3); 83 assert(c.size() == 4); 84 for (int j = 0; j < c.size(); ++j) 85 assert(c[j] == j); 86 c.push_back(4); 87 assert(c.size() == 5); 88 for (int j = 0; j < c.size(); ++j) 89 assert(c[j] == j); 90 } 91 #endif 92 } 93