-
Notifications
You must be signed in to change notification settings - Fork 0
/
vector_test.cpp
78 lines (52 loc) · 2.82 KB
/
vector_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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* vector_test.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ariahi <ariahi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/14 21:27:07 by ariahi #+# #+# */
/* Updated: 2023/02/14 21:27:08 by ariahi ### ########.fr */
/* */
/* ************************************************************************** */
#include "common.hpp"
int vector_unit_tests()
{
std::cout << YELLOW << "============================ 1 CONSTRUCTORS =======================" << RESET << std::endl ;
std::cout << "===== Default constructor =====" << std::endl << std::endl;
ft::vector<int> myvector;
std::vector<int> stdvector;
for (int i = 0; i < 10; i++)
{
myvector.push_back(i);
}
for (int i = 0; i < 10; i++)
{
stdvector.push_back(i);
}
std::cout << "===== fill constructor =====" << std::endl << std::endl;
ft::vector<int> myvector2(10, 69);
std::vector<int> stdvector2(10, 69);
std::cout << GREEN << "===== OK =====" << RESET << std::endl;
sleep(1);
std::cout << YELLOW << "============================ 2 Iterators =======================" << RESET << std::endl ;
std::cout << "===== begin =====" << std::endl << std::endl;
ft::vector<int>::iterator ft_it = myvector.begin();
std::vector<int>::iterator std_it = stdvector.begin();
std::cout << "the begin of ft_it is: " << *ft_it << std::endl;
std::cout << "the begin of std_it is: " << *std_it << std::endl;
std::cout << GREEN << "===== OK =====" << RESET << std::endl;
sleep(1);
std::cout << YELLOW << "============================ 3 Size =======================" << RESET << std::endl ;
std::cout << "===== size =====" << std::endl << std::endl;
std::cout << "the size of myvector is: " << myvector.size() << std::endl;
std::cout << "the size of stdvector is: " << stdvector.size() << std::endl;
std::cout << GREEN << "===== OK =====" << RESET << std::endl;
sleep(1);
std::cout << YELLOW << "============================ 4 - Element access =======================" << RESET << std::endl ;
std::cout << "===== operator[] =====" << std::endl << std::endl;
std::cout << "the element of myvector[2] is: " << myvector[2] << std::endl;
std::cout << "the element of stdvector[2] is: " << stdvector[2] << std::endl;
std::cout << GREEN << "===== OK =====" << RESET << std::endl;
return (0);
}