This commit is contained in:
2026-02-16 23:36:12 +01:00
commit 9bea74be7e
4 changed files with 288 additions and 0 deletions

104
ex00/main.cpp Normal file
View File

@@ -0,0 +1,104 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hadi <hadi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/02/16 22:32:41 by hadi #+# #+# */
/* Updated: 2026/02/16 23:35:56 by hadi ### ########.fr */
/* */
/* ************************************************************************** */
#include "Bureaucrat/Bureaucrat.hpp"
int main()
{
std::cout << "---- ex00 tests ----" << std::endl;
try {
std::cout << "-> Bureaucrat with grade 0" << std::endl;
Bureaucrat hadi("Hadi", 0);
} catch (std::exception &e) {
std::cout << e.what() << std::endl << std::endl;
}
try {
std::cout << "-> Bureaucrat with grade 1" << std::endl;
Bureaucrat hadi("Hadi", 1);
std::cout << hadi << std::endl;
} catch (std::exception &e) {
std::cout << e.what() << std::endl;
}
try {
std::cout << "-> Bureaucrat with grade 150" << std::endl;
Bureaucrat hadi("Hadi", 150);
std::cout << hadi << std::endl;
} catch (std::exception &e) {
std::cout << e.what() << std::endl;
}
try {
std::cout << "-> Bureaucrat with grade 151" << std::endl;
Bureaucrat hadi("Hadi", 151);
std::cout << hadi << std::endl;
} catch (std::exception &e) {
std::cout << e.what() << std::endl << std::endl;
}
try {
std::cout << "-> Try increment grade from 1" << std::endl;
Bureaucrat hadi("Hadi", 1);
std::cout << hadi;
hadi.incrementGrade();
std::cout << hadi;
} catch (std::exception &e) {
std::cout << e.what() << std::endl << std::endl;
}
try {
std::cout << "-> Try increment grade from 2" << std::endl;
Bureaucrat hadi("Hadi", 2);
std::cout << hadi;
hadi.incrementGrade();
std::cout << hadi;
} catch (std::exception &e) {
std::cout << e.what() << std::endl << std::endl;
}
try {
std::cout << std::endl
<< "-> Try decrement grade from 150" << std::endl;
Bureaucrat hadi("Hadi", 150);
std::cout << hadi;
hadi.decrementGrade();
std::cout << hadi;
} catch (std::exception &e) {
std::cout << e.what() << std::endl << std::endl;
}
try {
std::cout << "-> Try decrement grade from 149" << std::endl;
Bureaucrat hadi("Hadi", 149);
std::cout << hadi;
hadi.decrementGrade();
std::cout << hadi;
} catch (std::exception &e) {
std::cout << e.what() << std::endl << std::endl;
}
return (0);
}