d05 ex02 ok pour Shrubbery form

This commit is contained in:
hugogogo
2022-03-04 20:58:15 +01:00
parent 130b228a2f
commit 0a5827f3a1
14 changed files with 297 additions and 194 deletions

View File

@@ -1,64 +1,82 @@
#include "Bureaucrat.hpp"
#include "AForm.hpp"
#include "ShrubberyCreationForm.hpp"
#define N_TEST "5"
int main() {
int i = 0;
std::cout << B_YELLOW "\n[1/" N_TEST "] test too high :" RESET "\n";
std::cout << B_YELLOW "\n[" << ++i << "/" N_TEST "] "
<< "Shrubbery ok :" RESET "\n";
{
try {
Bureaucrat b("clarence", 151);
}
catch (std::exception& e) {
std::cout << e.what() << "\n";
}
Bureaucrat b("natasha", 50);
ShrubberyCreationForm s("sekoia");
std::cout << s << '\n';
std::cout << b << '\n';
std::cout << B_BLUE "b.signForm :" RESET "\n";
b.signForm(s);
b.executeForm(s);
std::cout << s << '\n';
}
std::cout << B_YELLOW "\n[2/" N_TEST "] test signe ko :" RESET "\n";
std::cout << B_YELLOW "\n[" << ++i << "/" N_TEST "] "
<< "Shrubbery too low signe and execute :" RESET "\n";
{
{
Bureaucrat b("mikel", 50);
Form f("serpa_hell", 30, 100);
Bureaucrat b("jordan", 150);
ShrubberyCreationForm s("chemney");
std::cout << f << '\n';
std::cout << b << '\n';
std::cout << B_BLUE "b.signForm :" RESET "\n";
b.signForm(f);
std::cout << f << '\n';
}
std::cout << s << '\n';
std::cout << b << '\n';
std::cout << B_BLUE "b.signForm :" RESET "\n";
b.signForm(s);
b.executeForm(s);
std::cout << s << '\n';
}
std::cout << B_YELLOW "\n[3/" N_TEST "] test signe ok :" RESET "\n";
std::cout << B_YELLOW "\n[" << ++i << "/" N_TEST "] "
<< "Shrubbery too low execute only :" RESET "\n";
{
{
Bureaucrat b("coran", 50);
Form f("serpa_death", 70, 100);
Bureaucrat b("bernadette", 140);
ShrubberyCreationForm s("rutabaga");
std::cout << f << '\n';
std::cout << b << '\n';
std::cout << B_BLUE "b.signForm :" RESET "\n";
b.signForm(f);
std::cout << f << '\n';
}
std::cout << s << '\n';
std::cout << b << '\n';
std::cout << B_BLUE "b.signForm :" RESET "\n";
b.signForm(s);
b.executeForm(s);
std::cout << s << '\n';
}
std::cout << B_YELLOW "\n[4/" N_TEST "] test form too high :" RESET "\n";
std::cout << B_YELLOW "\n[" << ++i << "/" N_TEST "] "
<< "Bureaucrat copy test :" RESET "\n";
{
try {
Form f("serpa_horror", 155, 100);
}
catch (std::exception& e) {
std::cout << e.what() << "\n";
}
Bureaucrat b1("pantoufle", 14);
Bureaucrat b2(b1);
std::cout << b1 << "\n";
std::cout << b2 << "\n";
}
std::cout << B_YELLOW "\n[5/" N_TEST "] test form too low :" RESET "\n";
std::cout << B_YELLOW "\n[" << ++i << "/" N_TEST "] "
<< "Shrubbery copy test :" RESET "\n";
{
ShrubberyCreationForm s1("rutabaga");
ShrubberyCreationForm s2(s1);
std::cout << s1 << "\n";
std::cout << s2 << "\n";
}
std::cout << B_YELLOW "\n[" << ++i << "/" N_TEST "] "
<< "Robotomy :" RESET "\n";
{
}
std::cout << B_YELLOW "\n[" << ++i << "/" N_TEST "] "
<< "Presidential :" RESET "\n";
{
try {
Form f("serpa_starvation", 70, 0);
}
catch (std::exception& e) {
std::cout << e.what() << "\n";
}
}
std::cout << "\n";