Эх сурвалжийг харах

Improve code quality in time module

Patrick-Christopher Mattulat 10 сар өмнө
parent
commit
b2fcf5c690

+ 9 - 9
include/ls-std/time/Date.hpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-08-14
- * Changed:         2023-05-19
+ * Changed:         2024-05-31
  *
  * */
 
@@ -12,11 +12,11 @@
 
 #include <ctime>
 #include <ls-std/core/Class.hpp>
-#include <ls-std/os/dynamic-goal.hpp>
+#include <ls-std/core/definition.hpp>
 
 namespace ls::std::time
 {
-  class LS_STD_DYNAMIC_GOAL Date : public ls::std::core::Class
+  ls_std_class Date final : public core::Class
   {
     public:
 
@@ -25,15 +25,15 @@ namespace ls::std::time
 
       // arithmetic operators
 
-      ls::std::time::Date &operator+(int _value);
-      ls::std::time::Date &operator-(int _value);
-      ls::std::time::Date &operator+=(int _value);
-      ls::std::time::Date &operator-=(int _value);
+      Date &operator+(int _value);
+      Date &operator-(int _value);
+      Date &operator+=(int _value);
+      Date &operator-=(int _value);
 
       // additional functionality
 
-      [[nodiscard]] bool after(const ls::std::time::Date &_foreignDate) const;
-      [[nodiscard]] bool before(const ls::std::time::Date &_foreignDate) const;
+      [[nodiscard]] bool after(const Date &_foreignDate) const;
+      [[nodiscard]] bool before(const Date &_foreignDate) const;
       [[nodiscard]] int getDay() const;
       [[nodiscard]] int getHour() const;
       [[nodiscard]] int getMinute() const;

+ 24 - 25
include/ls-std/time/common/DateParameter.hpp

@@ -3,50 +3,49 @@
 * Company:         Lynar Studios
 * E-Mail:          webmaster@lynarstudios.com
 * Created:         2023-03-29
-* Changed:         2023-03-31
+* Changed:         2024-05-31
 *
 * */
 
 #ifndef LS_STD_DATE_PARAMETER_HPP
 #define LS_STD_DATE_PARAMETER_HPP
 
-#include <cstdint>
-#include <ls-std/os/dynamic-goal.hpp>
+#include <ls-std/core/definition.hpp>
 #include <ls-std/time/type/DateParameterTypes.hpp>
 
 namespace ls::std::time
 {
-  class LS_STD_DYNAMIC_GOAL DateParameter
+  ls_std_class DateParameter
   {
     public:
 
-      DateParameter(ls::std::time::type::Year _year, ls::std::time::type::Month _month, ls::std::time::type::Day _day, ls::std::time::type::Hour _hour, ls::std::time::type::Minute _minute, ls::std::time::type::Second _second);
+      DateParameter(type::Year _year, type::Month _month, type::Day _day, type::Hour _hour, type::Minute _minute, type::Second _second);
       DateParameter();
       ~DateParameter();
 
-      bool operator==(const ls::std::time::DateParameter &_dateParameter) const;
-
-      [[nodiscard]] ls::std::time::type::Day getDay() const;
-      [[nodiscard]] ls::std::time::type::Hour getHour() const;
-      [[nodiscard]] ls::std::time::type::Minute getMinute() const;
-      [[nodiscard]] ls::std::time::type::Month getMonth() const;
-      [[nodiscard]] ls::std::time::type::Second getSecond() const;
-      [[nodiscard]] ls::std::time::type::Year getYear() const;
-      void setDay(ls::std::time::type::Day _day);
-      void setHour(ls::std::time::type::Hour _hour);
-      void setMinute(ls::std::time::type::Minute _minute);
-      void setMonth(ls::std::time::type::Month _month);
-      void setSecond(ls::std::time::type::Second _second);
-      void setYear(ls::std::time::type::Year _year);
+      bool operator==(const DateParameter &_dateParameter) const;
+
+      [[nodiscard]] type::Day getDay() const;
+      [[nodiscard]] type::Hour getHour() const;
+      [[nodiscard]] type::Minute getMinute() const;
+      [[nodiscard]] type::Month getMonth() const;
+      [[nodiscard]] type::Second getSecond() const;
+      [[nodiscard]] type::Year getYear() const;
+      void setDay(type::Day _day);
+      void setHour(type::Hour _hour);
+      void setMinute(type::Minute _minute);
+      void setMonth(type::Month _month);
+      void setSecond(type::Second _second);
+      void setYear(type::Year _year);
 
     private:
 
-      ls::std::time::type::Day day{};
-      ls::std::time::type::Hour hour{};
-      ls::std::time::type::Minute minute{};
-      ls::std::time::type::Month month{};
-      ls::std::time::type::Second second{};
-      ls::std::time::type::Year year{};
+      type::Day day{};
+      type::Hour hour{};
+      type::Minute minute{};
+      type::Month month{};
+      type::Second second{};
+      type::Year year{};
   };
 }
 

+ 5 - 5
include/ls-std/time/common/DateParameterMapper.hpp

@@ -3,7 +3,7 @@
 * Company:         Lynar Studios
 * E-Mail:          webmaster@lynarstudios.com
 * Created:         2023-03-31
-* Changed:         2023-04-01
+* Changed:         2024-05-31
 *
 * */
 
@@ -11,7 +11,7 @@
 #define LS_STD_DATE_PARAMETER_MAPPER_HPP
 
 #include "DateParameter.hpp"
-#include <ls-std/os/dynamic-goal.hpp>
+#include <ls-std/core/definition.hpp>
 #include <ls-std/time/type/DateParameterTypes.hpp>
 #ifdef _WIN32
   #include <windows.h>
@@ -19,7 +19,7 @@
 
 namespace ls::std::time
 {
-  class LS_STD_DYNAMIC_GOAL DateParameterMapper
+  ls_std_class DateParameterMapper
   {
     public:
 
@@ -27,10 +27,10 @@ namespace ls::std::time
       ~DateParameterMapper();
 
 #if defined(unix) || defined(__APPLE__)
-      [[nodiscard]] static ls::std::time::type::UnixTimestamp toUnixTimestamp(const ls::std::time::DateParameter &_dateParameter);
+      [[nodiscard]] static type::UnixTimestamp toUnixTimestamp(const DateParameter &_dateParameter);
 #endif
 #ifdef _WIN32
-      [[nodiscard]] static SYSTEMTIME toWindowsSystemTime(const ls::std::time::DateParameter &_dateParameter);
+      [[nodiscard]] static SYSTEMTIME toWindowsSystemTime(const DateParameter &_dateParameter);
 #endif
   };
 }

+ 4 - 4
include/ls-std/time/common/jni/JniDateParameterMapper.hpp

@@ -3,27 +3,27 @@
 * Company:         Lynar Studios
 * E-Mail:          webmaster@lynarstudios.com
 * Created:         2023-04-09
-* Changed:         2023-04-10
+* Changed:         2024-05-31
 *
 * */
 
 #ifndef LS_STD_JNI_DATE_PARAMETER_MAPPER_HPP
 #define LS_STD_JNI_DATE_PARAMETER_MAPPER_HPP
 
+#include <ls-std/core/definition.hpp>
 #include <ls-std/core/jni/JniClass.hpp>
-#include <ls-std/os/dynamic-goal.hpp>
 #include <ls-std/time/common/DateParameter.hpp>
 
 namespace ls::std::time::experimental
 {
-  class LS_STD_DYNAMIC_GOAL JniDateParameterMapper
+  ls_std_class JniDateParameterMapper
   {
     public:
 
       JniDateParameterMapper();
       ~JniDateParameterMapper();
 
-      [[nodiscard]] static ls::std::time::DateParameter toDateParameter(const ls::std::core::experimental::JniClass &_javaClass);
+      [[nodiscard]] static DateParameter toDateParameter(const core::experimental::JniClass &_javaClass);
   };
 }
 

+ 4 - 4
include/ls-std/time/system-time/IClock.hpp

@@ -3,26 +3,26 @@
 * Company:         Lynar Studios
 * E-Mail:          webmaster@lynarstudios.com
 * Created:         2023-03-31
-* Changed:         2023-03-31
+* Changed:         2024-05-31
 *
 * */
 
 #ifndef LS_STD_I_CLOCK_HPP
 #define LS_STD_I_CLOCK_HPP
 
-#include <ls-std/os/dynamic-goal.hpp>
+#include <ls-std/core/definition.hpp>
 #include <ls-std/time/common/DateParameter.hpp>
 
 namespace ls::std::time
 {
-  class LS_STD_DYNAMIC_GOAL IClock
+  ls_std_class IClock
   {
     public:
 
       IClock();
       virtual ~IClock();
 
-      virtual bool setTime(const ls::std::time::DateParameter &_dateParameter) = 0;
+      virtual bool setTime(const DateParameter &_dateParameter) = 0;
   };
 }
 

+ 4 - 5
include/ls-std/time/system-time/PosixClock.hpp

@@ -3,7 +3,7 @@
 * Company:         Lynar Studios
 * E-Mail:          webmaster@lynarstudios.com
 * Created:         2023-03-15
-* Changed:         2023-04-01
+* Changed:         2024-05-31
 *
 * */
 
@@ -11,19 +11,18 @@
 #define LS_STD_POSIX_CLOCK_HPP
 
 #include "IClock.hpp"
-#include <cstdint>
-#include <ls-std/time/type/DateParameterTypes.hpp>
+#include <ls-std/core/definition.hpp>
 
 namespace ls::std::time
 {
-  class PosixClock : public ls::std::time::IClock
+  ls_std_class PosixClock final : public IClock
   {
     public:
 
       PosixClock();
       ~PosixClock() noexcept override;
 
-      [[nodiscard]] bool setTime(const ls::std::time::DateParameter &_dateParameter) override;
+      [[nodiscard]] bool setTime(const DateParameter &_dateParameter) override;
   };
 }
 

+ 5 - 8
include/ls-std/time/system-time/SystemTime.hpp

@@ -3,7 +3,7 @@
 * Company:         Lynar Studios
 * E-Mail:          webmaster@lynarstudios.com
 * Created:         2023-03-07
-* Changed:         2023-05-18
+* Changed:         2024-05-31
 *
 * */
 
@@ -11,29 +11,26 @@
 #define LS_STD_SYSTEM_TIME_HPP
 
 #include "SystemTimeParameter.hpp"
-#include <cstdint>
 #include <ls-std/core/Class.hpp>
-#include <ls-std/os/dynamic-goal.hpp>
 #include <ls-std/time/common/DateParameter.hpp>
-#include <ls-std/time/type/DateParameterTypes.hpp>
 #include <memory>
 #include <string>
 
 namespace ls::std::time
 {
-  class LS_STD_DYNAMIC_GOAL SystemTime : public ls::std::core::Class
+  ls_std_class SystemTime final : public core::Class
   {
     public:
 
-      explicit SystemTime(const ::std::shared_ptr<ls::std::time::SystemTimeParameter> &_parameter);
+      explicit SystemTime(const ::std::shared_ptr<SystemTimeParameter> &_parameter);
       SystemTime();
       ~SystemTime() noexcept override;
 
-      [[nodiscard]] bool set(const ls::std::time::DateParameter &_dateParameter) const;
+      [[nodiscard]] bool set(const DateParameter &_dateParameter) const;
 
     private:
 
-      ::std::shared_ptr<ls::std::time::SystemTimeParameter> parameter{};
+      ::std::shared_ptr<SystemTimeParameter> parameter{};
 
       [[nodiscard]] static ::std::string _fetchClassName();
       void _generateParameter();

+ 6 - 6
include/ls-std/time/system-time/SystemTimeParameter.hpp

@@ -3,7 +3,7 @@
 * Company:         Lynar Studios
 * E-Mail:          webmaster@lynarstudios.com
 * Created:         2023-03-15
-* Changed:         2023-05-18
+* Changed:         2024-05-31
 *
 * */
 
@@ -11,24 +11,24 @@
 #define LS_STD_SYSTEM_TIME_PARAMETER_HPP
 
 #include "IClock.hpp"
-#include <ls-std/os/dynamic-goal.hpp>
+#include <ls-std/core/definition.hpp>
 #include <memory>
 
 namespace ls::std::time
 {
-  class LS_STD_DYNAMIC_GOAL SystemTimeParameter
+  ls_std_class SystemTimeParameter
   {
     public:
 
       SystemTimeParameter();
       ~SystemTimeParameter();
 
-      [[nodiscard]] ::std::shared_ptr<ls::std::time::IClock> getClock() const;
-      void setClock(const ::std::shared_ptr<ls::std::time::IClock> &_clock);
+      [[nodiscard]] ::std::shared_ptr<IClock> getClock() const;
+      void setClock(const ::std::shared_ptr<IClock> &_clock);
 
     private:
 
-      ::std::shared_ptr<ls::std::time::IClock> clock{};
+      ::std::shared_ptr<IClock> clock{};
   };
 }
 

+ 4 - 4
include/ls-std/time/system-time/WindowsClock.hpp

@@ -3,7 +3,7 @@
 * Company:         Lynar Studios
 * E-Mail:          webmaster@lynarstudios.com
 * Created:         2023-04-01
-* Changed:         2023-04-01
+* Changed:         2024-05-31
 *
 * */
 
@@ -11,18 +11,18 @@
 #define LS_STD_WINDOW_CLOCK_HPP
 
 #include "IClock.hpp"
-#include <ls-std/os/dynamic-goal.hpp>
+#include <ls-std/core/definition.hpp>
 
 namespace ls::std::time
 {
-  class LS_STD_DYNAMIC_GOAL WindowsClock : public ls::std::time::IClock
+  ls_std_class WindowsClock : public IClock
   {
     public:
 
       WindowsClock();
       ~WindowsClock() noexcept override;
 
-      [[nodiscard]] bool setTime(const ls::std::time::DateParameter &_dateParameter) override;
+      [[nodiscard]] bool setTime(const DateParameter &_dateParameter) override;
   };
 }
 

+ 3 - 1
include/ls-std/time/type/DateParameterTypes.hpp

@@ -3,13 +3,15 @@
 * Company:         Lynar Studios
 * E-Mail:          webmaster@lynarstudios.com
 * Created:         2023-03-29
-* Changed:         2023-03-31
+* Changed:         2024-05-31
 *
 * */
 
 #ifndef LS_STD_DATE_PARAMETER_TYPES_HPP
 #define LS_STD_DATE_PARAMETER_TYPES_HPP
 
+#include <cstdint>
+
 namespace ls::std::time::type
 {
   using Day = uint8_t;

+ 8 - 8
source/ls-std/time/Date.cpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-08-14
- * Changed:         2023-05-24
+ * Changed:         2024-05-31
  *
  * */
 
@@ -28,25 +28,25 @@ Date::Date() : Class("Date")
 
 Date::~Date() noexcept = default;
 
-Date &Date::operator+(int _value)
+Date &Date::operator+(const int _value)
 {
   this->_incrementByDays(_value);
   return *this;
 }
 
-Date &Date::operator-(int _value)
+Date &Date::operator-(const int _value)
 {
   this->_decrementByDays(_value);
   return *this;
 }
 
-Date &Date::operator+=(int _value)
+Date &Date::operator+=(const int _value)
 {
   this->_incrementByDays(_value);
   return *this;
 }
 
-Date &Date::operator-=(int _value)
+Date &Date::operator-=(const int _value)
 {
   this->_decrementByDays(_value);
   return *this;
@@ -97,7 +97,7 @@ time_t Date::getTime() const
   return this->timestamp;
 }
 
-void Date::setTime(time_t _timestamp)
+void Date::setTime(const time_t _timestamp)
 {
   this->timestamp = _timestamp;
   this->_init();
@@ -111,12 +111,12 @@ string Date::toString() const
   return _stream.str();
 }
 
-void Date::_decrementByDays(int _value)
+void Date::_decrementByDays(const int _value)
 {
   this->timestamp -= (_value * 86400);
 }
 
-void Date::_incrementByDays(int _value)
+void Date::_incrementByDays(const int _value)
 {
   this->timestamp += (_value * 86400);
 }

+ 8 - 8
source/ls-std/time/common/DateParameter.cpp

@@ -3,7 +3,7 @@
 * Company:         Lynar Studios
 * E-Mail:          webmaster@lynarstudios.com
 * Created:         2023-03-29
-* Changed:         2023-05-17
+* Changed:         2024-05-31
 *
 * */
 
@@ -17,7 +17,7 @@ using ls::std::time::type::Month;
 using ls::std::time::type::Second;
 using ls::std::time::type::Year;
 
-DateParameter::DateParameter(Year _year, Month _month, Day _day, Hour _hour, Minute _minute, Second _second) : day(_day), hour(_hour), minute(_minute), month(_month), second(_second), year(_year)
+DateParameter::DateParameter(const Year _year, const Month _month, const Day _day, const Hour _hour, const Minute _minute, const Second _second) : day(_day), hour(_hour), minute(_minute), month(_month), second(_second), year(_year)
 {}
 
 DateParameter::DateParameter() = default;
@@ -59,32 +59,32 @@ Year DateParameter::getYear() const
   return this->year;
 }
 
-void DateParameter::setDay(Day _day)
+void DateParameter::setDay(const Day _day)
 {
   this->day = _day;
 }
 
-void DateParameter::setHour(Hour _hour)
+void DateParameter::setHour(const Hour _hour)
 {
   this->hour = _hour;
 }
 
-void DateParameter::setMinute(Minute _minute)
+void DateParameter::setMinute(const Minute _minute)
 {
   this->minute = _minute;
 }
 
-void DateParameter::setMonth(Month _month)
+void DateParameter::setMonth(const Month _month)
 {
   this->month = _month;
 }
 
-void DateParameter::setSecond(Second _second)
+void DateParameter::setSecond(const Second _second)
 {
   this->second = _second;
 }
 
-void DateParameter::setYear(Year _year)
+void DateParameter::setYear(const Year _year)
 {
   this->year = _year;
 }

+ 3 - 3
source/ls-std/time/common/DateParameterMapper.cpp

@@ -3,7 +3,7 @@
 * Company:         Lynar Studios
 * E-Mail:          webmaster@lynarstudios.com
 * Created:         2023-03-31
-* Changed:         2023-05-17
+* Changed:         2024-05-31
 *
 * */
 
@@ -25,7 +25,7 @@ UnixTimestamp DateParameterMapper::toUnixTimestamp(const DateParameter &_datePar
 {
   time_t rawTime{};
   ::time(&rawTime);
-  struct tm timeInfo
+  tm timeInfo
   {
   };
   localtime_r(&rawTime, &timeInfo);
@@ -38,7 +38,7 @@ UnixTimestamp DateParameterMapper::toUnixTimestamp(const DateParameter &_datePar
   timeInfo.tm_sec = _dateParameter.getSecond();
   timeInfo.tm_isdst = -1;
 
-  return (UnixTimestamp) mktime(&timeInfo);
+  return static_cast<UnixTimestamp>(mktime(&timeInfo));
 }
 #endif
 

+ 3 - 3
source/ls-std/time/system-time/PosixClock.cpp

@@ -3,7 +3,7 @@
 * Company:         Lynar Studios
 * E-Mail:          webmaster@lynarstudios.com
 * Created:         2023-03-15
-* Changed:         2023-03-31
+* Changed:         2024-05-31
 *
 * */
 
@@ -22,7 +22,7 @@ PosixClock::~PosixClock() noexcept = default;
 
 bool PosixClock::setTime(const DateParameter &_dateParameter)
 {
-  UnixTimestamp timestamp = DateParameterMapper::toUnixTimestamp(_dateParameter);
-  timespec timespec{timestamp, 0};
+  const UnixTimestamp timestamp = DateParameterMapper::toUnixTimestamp(_dateParameter);
+  const timespec timespec{timestamp, 0};
   return clock_settime(CLOCK_REALTIME, &timespec) == 0;
 }

+ 2 - 2
source/ls-std/time/system-time/SystemTime.cpp

@@ -3,7 +3,7 @@
 * Company:         Lynar Studios
 * E-Mail:          webmaster@lynarstudios.com
 * Created:         2023-03-15
-* Changed:         2023-05-18
+* Changed:         2024-05-31
 *
 * */
 
@@ -40,7 +40,7 @@ SystemTime::SystemTime(const shared_ptr<SystemTimeParameter> &_parameter) : Clas
   NullPointerArgumentEvaluator{_parameter}.evaluate();
 }
 
-SystemTime::SystemTime() : Class(SystemTime::_fetchClassName())
+SystemTime::SystemTime() : Class(_fetchClassName())
 {
   this->_generateParameter();
 }

+ 22 - 22
test/cases/time/DateTest.cpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-08-14
- * Changed:         2023-03-25
+ * Changed:         2024-05-31
  *
  * */
 
@@ -31,7 +31,7 @@ namespace
   TEST_F(DateTest, operator_add)
   {
     Date date{};
-    time_t timestamp = date.getTime();
+    const time_t timestamp = date.getTime();
 
     date = date + 1;
     ASSERT_EQ(timestamp + 86400, date.getTime());
@@ -40,7 +40,7 @@ namespace
   TEST_F(DateTest, operator_add_with_negative_value)
   {
     Date date{};
-    time_t timestamp = date.getTime();
+    const time_t timestamp = date.getTime();
 
     date = date + (-1);
     ASSERT_EQ(timestamp - 86400, date.getTime());
@@ -49,7 +49,7 @@ namespace
   TEST_F(DateTest, operator_subtraction)
   {
     Date date{};
-    time_t timestamp = date.getTime();
+    const time_t timestamp = date.getTime();
 
     date = date - 1;
     ASSERT_EQ(timestamp - 86400, date.getTime());
@@ -58,7 +58,7 @@ namespace
   TEST_F(DateTest, operator_subtraction_with_negative_value)
   {
     Date date{};
-    time_t timestamp = date.getTime();
+    const time_t timestamp = date.getTime();
 
     date = date - (-1);
     ASSERT_EQ(timestamp + 86400, date.getTime());
@@ -67,40 +67,40 @@ namespace
   TEST_F(DateTest, operator_plus_equals)
   {
     Date date{};
-    time_t timestamp = date.getTime();
+    const time_t timestamp = date.getTime();
 
     date += 2;
-    time_t expectedTimestamp = timestamp + 86400 * 2;
+    const time_t expectedTimestamp = timestamp + 86400 * 2;
     ASSERT_EQ(expectedTimestamp, date.getTime());
   }
 
   TEST_F(DateTest, operator_plus_equals_with_negative_value)
   {
     Date date{};
-    time_t timestamp = date.getTime();
+    const time_t timestamp = date.getTime();
 
     date += -2;
-    time_t expectedTimestamp = timestamp - 86400 * 2;
+    const time_t expectedTimestamp = timestamp - 86400 * 2;
     ASSERT_EQ(expectedTimestamp, date.getTime());
   }
 
   TEST_F(DateTest, operator_minus_equals)
   {
     Date date{};
-    time_t timestamp = date.getTime();
+    const time_t timestamp = date.getTime();
 
     date -= 2;
-    time_t expectedTimestamp = timestamp - 86400 * 2;
+    const time_t expectedTimestamp = timestamp - 86400 * 2;
     ASSERT_EQ(expectedTimestamp, date.getTime());
   }
 
   TEST_F(DateTest, operator_minus_equals_with_negative_value)
   {
     Date date{};
-    time_t timestamp = date.getTime();
+    const time_t timestamp = date.getTime();
 
     date -= -2;
-    time_t expectedTimestamp = timestamp + 86400 * 2;
+    const time_t expectedTimestamp = timestamp + 86400 * 2;
     ASSERT_EQ(expectedTimestamp, date.getTime());
   }
 
@@ -108,7 +108,7 @@ namespace
 
   TEST_F(DateTest, after)
   {
-    Date date{}; // today
+    const Date date{}; // today
 
     Date referenceDate{};
     referenceDate = referenceDate - 1; // yesterday
@@ -118,7 +118,7 @@ namespace
 
   TEST_F(DateTest, after_is_before_refernce_date)
   {
-    Date date{}; // is today
+    const Date date{}; // is today
     Date referenceDate{};
 
     referenceDate = referenceDate + 1; // is tomorrow
@@ -131,14 +131,14 @@ namespace
     Date date{};
     date = date - 1; // yesterday
 
-    Date referenceDate{}; // today
+    const Date referenceDate{}; // today
 
     ASSERT_TRUE(date.before(referenceDate));
   }
 
   TEST_F(DateTest, before_is_after_reference_date)
   {
-    Date date{}; // today
+    const Date date{}; // today
     Date referenceDate{};
 
     referenceDate = referenceDate - 1; // yesterday
@@ -188,7 +188,7 @@ namespace
 
   TEST_F(DateTest, getTime)
   {
-    Date date{};
+    const Date date{};
     ASSERT_TRUE(date.getTime() > 0);
   }
 
@@ -211,10 +211,10 @@ namespace
 
   TEST_F(DateTest, toString)
   {
-    Date date{};
-    string regexSearchString = R"((\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}))";
-    regex _regex{regexSearchString};
-    string dateString = date.toString();
+    const Date date{};
+    const string regexSearchString = R"((\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}))";
+    const regex _regex{regexSearchString};
+    const string dateString = date.toString();
 
     ASSERT_TRUE(regex_match(dateString, _regex));
   }

+ 3 - 3
test/cases/time/common/DateParameterMapperTest.cpp

@@ -3,7 +3,7 @@
 * Company:         Lynar Studios
 * E-Mail:          webmaster@lynarstudios.com
 * Created:         2023-03-31
-* Changed:         2023-04-01
+* Changed:         2024-05-31
 *
 * */
 
@@ -45,8 +45,8 @@ namespace
 
   TEST_P(DateParameterMapperTest_Unix, toUnixTimestamp)
   {
-    DateParameter dateParameter = GetParam().second;
-    UnixTimestamp timestamp = DateParameterMapper::toUnixTimestamp(dateParameter);
+    const DateParameter dateParameter = GetParam().second;
+    const UnixTimestamp timestamp = DateParameterMapper::toUnixTimestamp(dateParameter);
 
     ASSERT_EQ(GetParam().first, timestamp);
   }

+ 12 - 12
test/cases/time/common/DateParameterTest.cpp

@@ -3,7 +3,7 @@
 * Company:         Lynar Studios
 * E-Mail:          webmaster@lynarstudios.com
 * Created:         2023-03-29
-* Changed:         2023-03-31
+* Changed:         2024-05-31
 *
 * */
 
@@ -25,7 +25,7 @@ namespace
 
   TEST_F(DateParameterTest, constructor)
   {
-    DateParameter parameter{1989, 6, 1, 10, 52, 13};
+    const DateParameter parameter{1989, 6, 1, 10, 52, 13};
 
     ASSERT_EQ(1989, parameter.getYear());
     ASSERT_EQ(6, parameter.getMonth());
@@ -37,53 +37,53 @@ namespace
 
   TEST_F(DateParameterTest, operator_equals)
   {
-    DateParameter requiredBirthday{1989, 6, 1, 10, 52, 13};
-    DateParameter hisBirthday{1989, 6, 1, 10, 52, 13};
+    const DateParameter requiredBirthday{1989, 6, 1, 10, 52, 13};
+    const DateParameter hisBirthday{1989, 6, 1, 10, 52, 13};
 
     ASSERT_TRUE(requiredBirthday == hisBirthday);
   }
 
   TEST_F(DateParameterTest, operator_equals_not_equals)
   {
-    DateParameter hisBirthday{1989, 6, 1, 10, 52, 00};
-    DateParameter herBirthday{1990, 10, 26, 11, 25, 00};
+    const DateParameter hisBirthday{1989, 6, 1, 10, 52, 00};
+    const DateParameter herBirthday{1990, 10, 26, 11, 25, 00};
 
     ASSERT_FALSE(herBirthday == hisBirthday);
   }
 
   TEST_F(DateParameterTest, getDay)
   {
-    DateParameter parameter{};
+    const DateParameter parameter{};
     ASSERT_EQ(0, parameter.getDay());
   }
 
   TEST_F(DateParameterTest, getHour)
   {
-    DateParameter parameter{};
+    const DateParameter parameter{};
     ASSERT_EQ(0, parameter.getHour());
   }
 
   TEST_F(DateParameterTest, getMinute)
   {
-    DateParameter parameter{};
+    const DateParameter parameter{};
     ASSERT_EQ(0, parameter.getMinute());
   }
 
   TEST_F(DateParameterTest, getMonth)
   {
-    DateParameter parameter{};
+    const DateParameter parameter{};
     ASSERT_EQ(0, parameter.getMonth());
   }
 
   TEST_F(DateParameterTest, getSecond)
   {
-    DateParameter parameter{};
+    const DateParameter parameter{};
     ASSERT_EQ(0, parameter.getSecond());
   }
 
   TEST_F(DateParameterTest, getYear)
   {
-    DateParameter parameter{};
+    const DateParameter parameter{};
     ASSERT_EQ(0, parameter.getYear());
   }
 

+ 5 - 5
test/cases/time/system-time/SystemTimeTest.cpp

@@ -3,7 +3,7 @@
 * Company:         Lynar Studios
 * E-Mail:          webmaster@lynarstudios.com
 * Created:         2023-03-15
-* Changed:         2023-05-18
+* Changed:         2024-05-31
 *
 * */
 
@@ -43,7 +43,7 @@ namespace
           {
             SystemTime systemTime{nullptr};
           }
-          catch (const IllegalArgumentException &_exception)
+          catch ([[maybe_unused]] const IllegalArgumentException &_exception)
           {
             throw;
           }
@@ -58,10 +58,10 @@ namespace
 
   TEST_F(SystemTimeTest, setTime)
   {
-    auto parameter = make_shared<SystemTimeParameter>();
-    auto posixClock = make_shared<MockClock>();
+    const auto parameter = make_shared<SystemTimeParameter>();
+    const auto posixClock = make_shared<MockClock>();
     parameter->setClock(posixClock);
-    auto birthday = DateParameter(1990, 10, 26, 11, 25, 00);
+    const auto birthday = DateParameter(1990, 10, 26, 11, 25, 00);
 
     EXPECT_CALL(*posixClock, setTime(birthday)).Times(AtLeast(1));
     ON_CALL(*posixClock, setTime(birthday)).WillByDefault(Return(true));