Website Summary Files Commits Branches @commit @diff @stats
path: root / tests / Test_DateTime.cpp
diff options
context:
space:
mode:
Commit3079c59db65b8498588254abf6979ca78a56b600 (patch)
Author
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-05-01 11:14:32 +0300
Committer
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-05-01 11:14:32 +0300
Files3a2b25e66c289c9be58d8b3706ae02fc9aedfa01 /tests/Test_DateTime.cpp
FMI-OOP-P1_TicketSystem-3079c59db65b8498588254abf6979ca78a56b600.tar
FMI-OOP-P1_TicketSystem-3079c59db65b8498588254abf6979ca78a56b600.tar.gz
FMI-OOP-P1_TicketSystem-3079c59db65b8498588254abf6979ca78a56b600.zip
Parentd6eb1cfde134235cd4826e4788be6de1a3d4bae2 (diff)
Autocommit at 01.05.2022 @ 11:14
1 files changed, 19 insertions, 6 deletions
-rw-r--r--tests/Test_DateTime.cpp25
diff --git a/tests/Test_DateTime.cpp b/tests/Test_DateTime.cpp
index 189e988..65763f2 100644
--- a/tests/Test_DateTime.cpp
+++ b/tests/Test_DateTime.cpp
@@ -1,3 +1,4 @@
+#include <stdexcept>
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "../doctest/doctest/doctest.h"
#include "../src/DateTime/DateTime.h"
@@ -6,12 +7,24 @@ TEST_SUITE_BEGIN("ClassDateTime");
TEST_SUITE("Constructors") {
TEST_CASE("Ctor_SavesValues_WhenGivenCorrectOnes") {
- DateTime dt(2, 49, 4, 12, 2022);
- CHECK_EQ(dt.get_hour(), 2);
- CHECK_EQ(dt.get_minute(), 49);
- CHECK_EQ(dt.get_day(), 4);
- CHECK_EQ(dt.get_month(), 12);
- CHECK_EQ(dt.get_year(), 2022);
+ unsigned short h = 5, m = 12, d = 19, M = 4, y = 2022;
+ DateTime dt(h, m, d, M, y);
+ CHECK_EQ(dt.get_hour(), h);
+ CHECK_EQ(dt.get_minute(), m);
+ CHECK_EQ(dt.get_day(), d);
+ CHECK_EQ(dt.get_month(), M);
+ CHECK_EQ(dt.get_year(), y);
+ }
+ TEST_CASE("Ctor_ThrowsInvalidArgumentException_WhenGivenIncorrectValues") {
+ unsigned short h = 5, m = 12, d = 19, M = 4, y = 2022;
+ SUBCASE("HourIsTooBig") { h = 194; }
+ SUBCASE("MinutesAreTooBig") { m = 7032; }
+ SUBCASE("DayIsZero") { d = 0; }
+ SUBCASE("DayIsTooBig") { d = 5721; }
+ SUBCASE("MonthIsZero") { M = 0; }
+ SUBCASE("MonthIsTooBig") { M = 15661; }
+
+ CHECK_THROWS_AS(DateTime dt(h, m, d, M, y), std::invalid_argument);
}
}