-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_wetieven.cpp
141 lines (104 loc) · 3.76 KB
/
main_wetieven.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#include <iostream> // for testing
#include <cassert> // for testing
//#include "pair.hpp"
#include "inc/ft_utility.hpp"
const std::string bool_to_str(const bool result)
{
return (result ? "TRUE" : "FALSE");
}
template <typename any_pair>
void print_pair(any_pair p)
{
std::cout << '|' << p.first << "| : |" << p.second << '|' << std::endl;
}
int main(int argc, char *argv[]) {
(void)argc;
(void)argv;
std::cout << "[ PAIR ]\n" << std::endl;
std::cout << "--- Parametric constructor ---\n" << std::endl;
std::cout << "pair<int, float> a(42, 3.14);" << std::endl;
std::cout << "v" << std::endl;
ft::pair<int, float> a(42, 3.14);
std::cout << std::endl;
std::cout << "print_pair(a);" << std::endl;
std::cout << "v" << std::endl;
print_pair(a);
std::cout << std::endl;
std::cout << "--- Copy constructor ---\n" << std::endl;
std::cout << "pair<float, double> b(a);" << std::endl;
std::cout << "v" << std::endl;
ft::pair<float, double> b(a);
std::cout << std::endl;
std::cout << "print_pair(b);" << std::endl;
std::cout << "v" << std::endl;
print_pair(b);
std::cout << std::endl;
std::cout << "pair<char, double> c(a);" << std::endl;
std::cout << "v" << std::endl;
ft::pair<char, double> c(a);
std::cout << std::endl;
std::cout << "print_pair(c);" << std::endl;
std::cout << "v" << std::endl;
print_pair(c);
std::cout << std::endl;
std::cout << "--- Default constructor ---\n" << std::endl;
std::cout << "pair<int, float> dflt;" << std::endl;
std::cout << "v" << std::endl;
ft::pair<int, float> dflt;
std::cout << std::endl;
std::cout << "--- Assignment operator ---\n" << std::endl;
std::cout << "dflt = c;" << std::endl;
std::cout << "v" << std::endl;
dflt = c;
std::cout << std::endl;
std::cout << "print_pair(dflt);" << std::endl;
std::cout << "v" << std::endl;
print_pair(dflt);
std::cout << std::endl;
std::cout << "--- Comparison operators ---\n" << std::endl;
std::cout << "assert(dflt == a);" << std::endl;
std::cout << "v" << std::endl;
assert(dflt == a);
std::cout << std::endl;
std::cout << "pair<char, char> ab('a', 'b');" << std::endl;
std::cout << "v" << std::endl;
ft::pair<char, char> ab('a', 'b');
std::cout << std::endl;
std::cout << "pair<char, char> ab2('a', 'b');" << std::endl;
std::cout << "v" << std::endl;
ft::pair<char, char> ab2('a', 'b');
std::cout << std::endl;
std::cout << "pair<char, char> ac('a', 'c');" << std::endl;
std::cout << "v" << std::endl;
ft::pair<char, char> ac('a', 'c');
std::cout << std::endl;
std::cout << "pair<char, char> bb('b', 'b');" << std::endl;
std::cout << "v" << std::endl;
ft::pair<char, char> bb('b', 'b');
std::cout << std::endl;
std::cout << "assert(ab != ac);" << std::endl;
assert(ab != ac);
std::cout << "assert(ab < ac);" << std::endl;
assert(ab < ac);
std::cout << "assert(!(ab2 < ab));" << std::endl;
assert(!(ab2 < ab));
std::cout << "assert(!(ac < ab));" << std::endl;
assert(!(ac < ab));
// std::cout << "std::cout << bool_to_str(ab > ac) << std::endl;" << std::endl;
// std::cout << "v" << std::endl;
// std::cout << bool_to_str(ab > ac) << std::endl;
// std::cout << std::endl;
std::cout << "assert(bb > ab);" << std::endl;
assert(bb > ab);
std::cout << "assert(ab <= ac);" << std::endl;
assert(ab <= ac);
std::cout << "assert(ab <= ab2);" << std::endl;
assert(ab <= ab2);
std::cout << "assert(ac <= bb);" << std::endl;
assert(ac <= bb);
std::cout << "assert(ab >= ab2);" << std::endl;
assert(ab >= ab2);
std::cout << "assert(bb >= ab);" << std::endl;
assert(bb >= ab);
return 0;
}