d05 ex00 bureaucrat ok

This commit is contained in:
Hugo LAMY
2022-02-28 15:47:00 +01:00
parent 8f6c8259c8
commit ce1bde6d2c
7 changed files with 236 additions and 23 deletions

View File

@@ -1,10 +1,79 @@
#include "Bureaucrat.hpp"
#define N_TEST "5"
int main() {
try
std::cout << B_YELLOW "\n[1/" N_TEST "] test too high :" RESET "\n";
{
try {
Bureaucrat b("clarence", 151);
}
catch (std::exception& e) {
std::cout << e.what() << "\n";
}
}
catch (std::exception & e)
std::cout << B_YELLOW "\n[2/" N_TEST "] test too low :" RESET "\n";
{
try {
Bureaucrat b("ellen", 0);
}
catch (std::exception& e) {
std::cout << e.what() << "\n";
}
}
std::cout << B_YELLOW "\n[3/" N_TEST "] test change grade :" RESET "\n";
{
try {
Bureaucrat b("pacome", 51);
std::cout << b << "\n";
b.gradeDown();
std::cout << b << "\n";
b.gradeUp();
std::cout << b << "\n";
}
catch (std::exception& e) {
std::cout << e.what() << "\n";
}
}
std::cout << B_YELLOW "\n[4/" N_TEST "] test reduce grade :" RESET "\n";
{
try
{
Bureaucrat b("colin", 145);
while (true)
{
b.gradeDown();
std::cout << b << "\n";
}
}
catch (std::exception& e)
{
std::cout << e.what() << "\n";
}
}
std::cout << B_YELLOW "\n[5/" N_TEST "] test increase grade :" RESET "\n";
{
try
{
Bureaucrat b("colin", 5);
while (true)
{
b.gradeUp();
std::cout << b << "\n";
}
}
catch (std::exception& e)
{
std::cout << e.what() << "\n";
}
}
std::cout << "\n";
return 0;
}