-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
76 lines (69 loc) · 2.54 KB
/
main.cpp
File metadata and controls
76 lines (69 loc) · 2.54 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: zelhajou <zelhajou@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/12/27 17:12:35 by zelhajou #+# #+# */
/* Updated: 2024/12/30 16:45:01 by zelhajou ### ########.fr */
/* */
/* ************************************************************************** */
#include "Bureaucrat.hpp"
#include "Intern.hpp"
int main()
{
try
{
Intern intern;
Bureaucrat boss("Boss", 1);
std::cout << "\n----- Test 1: Create and execute Shrubbery Creation Form -----\n";
{
AForm *form = intern.makeForm("shrubbery creation", "home");
if (form)
{
boss.signForm(*form);
boss.executeForm(*form);
delete form;
}
}
std::cout << "\n----- Test 2: Create and execute Robotomy Request Form -----\n";
{
AForm *form = intern.makeForm("robotomy request", "moulinex");
if (form)
{
boss.signForm(*form);
boss.executeForm(*form);
delete form;
}
}
std::cout << "\n----- Test 3: Create and execute Presidential Pardon Form -----\n";
{
AForm *form = intern.makeForm("presidential pardon", "prisoner");
if (form)
{
boss.signForm(*form);
boss.executeForm(*form);
delete form;
}
}
std::cout << "\n----- Test 4: Try to create an invalid form -----\n";
{
try
{
AForm *form = intern.makeForm("invalid form", "target");
if (form)
delete form;
}
catch (std::exception &e)
{
std::cout << "Error: " << e.what() << std::endl;
}
}
}
catch (std::exception &e)
{
std::cout << "Unexpected error: " << e.what() << std::endl;
}
return 0;
}