-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
107 lines (97 loc) · 1.82 KB
/
main.cpp
File metadata and controls
107 lines (97 loc) · 1.82 KB
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
#include "Bureaucrat.hpp"
#include "Form.hpp"
#include "print.hpp"
namespace Tests
{
void
signForm ()
{
Bureaucrat man ("man", 100);
Form job (42, 90, "job");
man.signForm (job);
Bureaucrat woman ("woman", 30);
Form car (40, 89, "car");
woman.signForm (car);
}
void
beSigned ()
{
Bureaucrat man ("man", 100);
Form motocycle (42, 90, "motocycle");
try
{
motocycle.beSigned (man);
}
catch (const std::exception &e)
{
print (e.what ());
}
}
void
formExceptions ()
{
try
{
Form highExecGrade (0, 100, "TestForm");
}
catch (const std::exception &e)
{
print (e.what ());
}
try
{
Form lowExecGrade (200, 100, "TestForm");
}
catch (const std::exception &e)
{
print (e.what ());
}
try
{
Form highSignGrade (100, 0, "TestForm");
}
catch (const std::exception &e)
{
print (e.what ());
}
try
{
Form lowSignGrade (100, 200, "TestForm");
}
catch (const std::exception &e)
{
print (e.what ());
}
}
void
overloarInsertion ()
{
Bureaucrat spiderMan ("spiderMan", 41);
Form web (42, 90, "web");
spiderMan.signForm (web);
std::cout << web << std::endl;
}
void
getters ()
{
Form dog (3, 90, "Dog");
print ("Name: " << dog.getName ());
print ("Sign grade " << dog.getSignGrade ());
print ("Exec grade " << dog.getExecGrade ());
print ("Bool if is signed: " << dog.isSigned ());
}
}
int
main (void)
{
print (GREEN TITTLE "Getters" RESET);
Tests::getters ();
print (GREEN TITTLE "Bureaucrat try to sign a form" RESET);
Tests::signForm ();
print (GREEN TITTLE "beSigned()" RESET);
Tests::beSigned ();
print (GREEN TITTLE "Form constructor exceptions" RESET);
Tests::formExceptions ();
print (GREEN TITTLE "Overload of insertion" RESET);
Tests::overloarInsertion ();
}