Website Summary Files Commits Branches @commit @diff @stats
path: root / tests / Test_DateTime.cpp
diff options
context:
space:
mode:
Commit991373dd1db0c4f9feb38cc77d61875de21bf89d (patch)
Author
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-05-01 11:29:37 +0300
Committer
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-05-01 11:29:37 +0300
Files8f3aef58f9e702c9932528a509661091d67d9d58 /tests/Test_DateTime.cpp
FMI-OOP-P1_TicketSystem-991373dd1db0c4f9feb38cc77d61875de21bf89d.tar
FMI-OOP-P1_TicketSystem-991373dd1db0c4f9feb38cc77d61875de21bf89d.tar.gz
FMI-OOP-P1_TicketSystem-991373dd1db0c4f9feb38cc77d61875de21bf89d.zip
Parent51c9c0acdc1e23cc8f28cae55dcc7a76d7659f77 (diff)
Autocommit at 01.05.2022 @ 11:29
1 files changed, 43 insertions, 4 deletions
-rw-r--r--tests/Test_DateTime.cpp47
diff --git a/tests/Test_DateTime.cpp b/tests/Test_DateTime.cpp
index 48da0c2..ac28b4a 100644
--- a/tests/Test_DateTime.cpp
+++ b/tests/Test_DateTime.cpp
@@ -38,19 +38,58 @@ TEST_SUITE("GettersAndSetters") {
}
TEST_CASE("HourSetter_ReturnTrue_WhenGivenCorrectValue") {
DateTime dt(h, m, d, M, y);
+ unsigned nh;
+ SUBCASE("SingleDigits") { nh = 2; }
+ SUBCASE("DoubleDigits") { nh = 10; }
+ SUBCASE("24hour") { nh = 17; }
+ SUBCASE("Zero") { nh = 0; }
- CHECK_UNARY(dt.set_hour(2));
+ CHECK_UNARY(dt.set_hour(nh));
}
TEST_CASE("HourSetter_SetsValue_WhenGivenCorrectValue") {
DateTime dt(h, m, d, M, y);
- dt.set_hour(9);
+ unsigned nh;
+ SUBCASE("SingleDigits") { nh = 2; }
+ SUBCASE("DoubleDigits") { nh = 10; }
+ SUBCASE("24hour") { nh = 17; }
+ SUBCASE("Zero") { nh = 0; }
+ dt.set_hour(nh);
- CHECK_EQ(dt.get_hour(), 9);
+ CHECK_EQ(dt.get_hour(), nh);
}
TEST_CASE("HourSetter_ReturnsFalse_WhenGivenIncorrectValue") {
DateTime dt(h, m, d, M, y);
+ unsigned nh;
+ SUBCASE("TooBig") { nh = 891; }
- CHECK_UNARY_FALSE(dt.set_hour(888));
+ CHECK_UNARY_FALSE(dt.set_hour(nh));
+ }
+
+ TEST_CASE("MinuteGetter_ReturnsCorrectValue_WhenCreatedWithValidValues") {
+ DateTime dt(h, m, d, M, y);
+
+ CHECK_EQ(dt.get_minute(), h);
+ }
+ TEST_CASE("MinuteSetter_ReturnTrue_WhenGivenCorrectValue") {
+ DateTime dt(h, m, d, M, y);
+ unsigned nm;
+ SUBCASE("SingleDigits") { nm = 2; }
+ SUBCASE("DoubleDigits") { nm = 10; }
+ SUBCASE("24hour") { nm = 17; }
+ SUBCASE("Zero") { nm = 0; }
+
+ CHECK_UNARY(dt.set_minute(nm));
+ }
+ TEST_CASE("MinuteSetter_SetsValue_WhenGivenCorrectValue") {
+ DateTime dt(h, m, d, M, y);
+ dt.set_minute(9);
+
+ CHECK_EQ(dt.get_minute(), 9);
+ }
+ TEST_CASE("MinuteSetter_ReturnsFalse_WhenGivenIncorrectValue") {
+ DateTime dt(h, m, d, M, y);
+
+ CHECK_UNARY_FALSE(dt.set_minute(888));
}
}