DateParameterTest.cpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2023-03-29
  6. * Changed: 2023-03-31
  7. *
  8. * */
  9. #include <gtest/gtest.h>
  10. #include <ls-std/ls-std-time.hpp>
  11. using ls::std::time::DateParameter;
  12. using testing::Test;
  13. namespace
  14. {
  15. class DateParameterTest : public Test
  16. {
  17. public:
  18. DateParameterTest() = default;
  19. ~DateParameterTest() override = default;
  20. };
  21. TEST_F(DateParameterTest, constructor)
  22. {
  23. DateParameter parameter{1989, 6, 1, 10, 52, 13};
  24. ASSERT_EQ(1989, parameter.getYear());
  25. ASSERT_EQ(6, parameter.getMonth());
  26. ASSERT_EQ(1, parameter.getDay());
  27. ASSERT_EQ(10, parameter.getHour());
  28. ASSERT_EQ(52, parameter.getMinute());
  29. ASSERT_EQ(13, parameter.getSecond());
  30. }
  31. TEST_F(DateParameterTest, operator_equals)
  32. {
  33. DateParameter requiredBirthday{1989, 6, 1, 10, 52, 13};
  34. DateParameter hisBirthday{1989, 6, 1, 10, 52, 13};
  35. ASSERT_TRUE(requiredBirthday == hisBirthday);
  36. }
  37. TEST_F(DateParameterTest, operator_equals_not_equals)
  38. {
  39. DateParameter hisBirthday{1989, 6, 1, 10, 52, 00};
  40. DateParameter herBirthday{1990, 10, 26, 11, 25, 00};
  41. ASSERT_FALSE(herBirthday == hisBirthday);
  42. }
  43. TEST_F(DateParameterTest, getDay)
  44. {
  45. DateParameter parameter{};
  46. ASSERT_EQ(0, parameter.getDay());
  47. }
  48. TEST_F(DateParameterTest, getHour)
  49. {
  50. DateParameter parameter{};
  51. ASSERT_EQ(0, parameter.getHour());
  52. }
  53. TEST_F(DateParameterTest, getMinute)
  54. {
  55. DateParameter parameter{};
  56. ASSERT_EQ(0, parameter.getMinute());
  57. }
  58. TEST_F(DateParameterTest, getMonth)
  59. {
  60. DateParameter parameter{};
  61. ASSERT_EQ(0, parameter.getMonth());
  62. }
  63. TEST_F(DateParameterTest, getSecond)
  64. {
  65. DateParameter parameter{};
  66. ASSERT_EQ(0, parameter.getSecond());
  67. }
  68. TEST_F(DateParameterTest, getYear)
  69. {
  70. DateParameter parameter{};
  71. ASSERT_EQ(0, parameter.getYear());
  72. }
  73. TEST_F(DateParameterTest, setDay)
  74. {
  75. DateParameter parameter{};
  76. parameter.setDay(1);
  77. ASSERT_EQ(1, parameter.getDay());
  78. }
  79. TEST_F(DateParameterTest, setHour)
  80. {
  81. DateParameter parameter{};
  82. parameter.setHour(10);
  83. ASSERT_EQ(10, parameter.getHour());
  84. }
  85. TEST_F(DateParameterTest, setMinute)
  86. {
  87. DateParameter parameter{};
  88. parameter.setMinute(52);
  89. ASSERT_EQ(52, parameter.getMinute());
  90. }
  91. TEST_F(DateParameterTest, setMonth)
  92. {
  93. DateParameter parameter{};
  94. parameter.setMonth(6);
  95. ASSERT_EQ(6, parameter.getMonth());
  96. }
  97. TEST_F(DateParameterTest, setSecond)
  98. {
  99. DateParameter parameter{};
  100. parameter.setSecond(13);
  101. ASSERT_EQ(13, parameter.getSecond());
  102. }
  103. TEST_F(DateParameterTest, setYear)
  104. {
  105. DateParameter parameter{};
  106. parameter.setYear(1989);
  107. ASSERT_EQ(1989, parameter.getYear());
  108. }
  109. }