-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
ex16_16_vec_test.cpp
48 lines (35 loc) · 1.27 KB
/
ex16_16_vec_test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "ex16_16_vec.h"
#include <iostream>
#include <string>
int main()
{
Vec<std::string> vec;
vec.reserve(6);
std::cout << "capacity(reserve to 6): " << vec.capacity() << std::endl;
vec.reserve(4);
std::cout << "capacity(reserve to 4): " << vec.capacity() << std::endl;
vec.push_back("hello");
vec.push_back("world");
vec.resize(4);
for (auto i = vec.begin(); i != vec.end(); ++i)
std::cout << *i << std::endl;
std::cout << "-EOF-" << std::endl;
vec.resize(1);
for (auto i = vec.begin(); i != vec.end(); ++i)
std::cout << *i << std::endl;
std::cout << "-EOF-" << std::endl;
Vec<std::string> vec_list{"hello", "world", "pezy"};
for (auto i = vec_list.begin(); i != vec_list.end(); ++i)
std::cout << *i << " ";
std::cout << std::endl;
// Test operator==
const Vec<std::string> const_vec_list{"hello", "world", "pezy"};
if (vec_list == const_vec_list)
for (const auto& str : const_vec_list) std::cout << str << " ";
std::cout << std::endl;
// Test operator<
const Vec<std::string> const_vec_list_small{"hello", "pezy", "ok"};
std::cout << (const_vec_list_small < const_vec_list) << std::endl;
// Test []
std::cout << const_vec_list_small[1] << std::endl;
}