From 90f2109e8733f9bee61544290e659e0659546c27 Mon Sep 17 00:00:00 2001 From: Camille Chauvet Date: Sun, 3 Sep 2023 11:41:35 +0000 Subject: [PATCH] add: form test --- ex01/src/main.cpp | 92 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/ex01/src/main.cpp b/ex01/src/main.cpp index d364f1e..b7ec015 100644 --- a/ex01/src/main.cpp +++ b/ex01/src/main.cpp @@ -3,6 +3,7 @@ int main() { + std::cout << "-------------Bureaucrat TEST-----------" << std::endl; std::cout << "Constructor too high grade" << std::endl; { try { @@ -91,4 +92,95 @@ int main() { std::cout << crat; } std::cout << std::endl; + + std::cout << "------------- Form TEST-----------" << std::endl; + + std::cout << "Constructor too high sign grade" << std::endl; + { + try { + Form("form", 42, 0); + } catch (std::exception &e) { + std::cout << e.what() << std::endl; + } + } + std::cout << std::endl; + + std::cout << "Constructor too low sign grade" << std::endl; + { + try { + Form("form", 42, 151); + } catch (std::exception &e) { + std::cout << e.what() << std::endl; + } + } + std::cout << std::endl; + + std::cout << "Constructor too high exec grade" << std::endl; + { + try { + Form("form", 0, 42); + } catch (std::exception &e) { + std::cout << e.what() << std::endl; + } + } + std::cout << std::endl; + + std::cout << "Constructor too low exec grade" << std::endl; + { + try { + Form("form", 151, 42); + } catch (std::exception &e) { + std::cout << e.what() << std::endl; + } + } + std::cout << std::endl; + + std::cout << "print" << std::endl; + { + Form form("form", 42, 42); + std::cout << form; + } + std::cout << std::endl; + + std::cout << "------------- Form Sign TEST-----------" << std::endl; + + std::cout << "Bureaucrat sign a Form" << std::endl; + { + Form form("form", 42, 42); + Bureaucrat crat("crat", 42); + + crat.signForm(form); + } + std::cout << std::endl; + + std::cout << "Too low Bureaucrat sign a Form" << std::endl; + { + Form form("form", 42, 1); + Bureaucrat crat("crat", 42); + try { + crat.signForm(form); + } catch (std::exception &e) { + std::cout << e.what() << std::endl; + } + } + std::cout << std::endl; + + std::cout << "High Bureaucrat sign a low Form" << std::endl; + { + Form form("form", 42, 150); + Bureaucrat crat("crat", 1); + + crat.signForm(form); + } + std::cout << std::endl; + + std::cout << "Form already sign" << std::endl; + { + Form form("form", 42, 150); + Bureaucrat crat("crat", 1); + + crat.signForm(form); + crat.signForm(form); + } + std::cout << std::endl; }