SystemTimeParameterTest.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2023-03-15
  6. * Changed: 2023-04-01
  7. *
  8. * */
  9. #include <gtest/gtest.h>
  10. #include <ls-std/ls-std-time.hpp>
  11. #include <memory>
  12. using ls::std::time::IClock;
  13. #if defined(unix) || defined(__APPLE__)
  14. using ls::std::time::PosixClock;
  15. #endif
  16. using ls::std::time::SystemTimeParameter;
  17. #ifdef _WIN32
  18. using ls::std::time::WindowsClock;
  19. #endif
  20. using std::make_shared;
  21. using std::shared_ptr;
  22. using testing::Test;
  23. namespace
  24. {
  25. class SystemTimeParameterTest : public Test
  26. {
  27. public:
  28. SystemTimeParameterTest() = default;
  29. ~SystemTimeParameterTest() override = default;
  30. };
  31. TEST_F(SystemTimeParameterTest, getClock)
  32. {
  33. ASSERT_TRUE(SystemTimeParameter{}.getClock() == nullptr);
  34. }
  35. TEST_F(SystemTimeParameterTest, setClock)
  36. {
  37. SystemTimeParameter parameter{};
  38. shared_ptr<IClock> clock{};
  39. #if defined(unix) || defined(__APPLE__)
  40. clock = make_shared<PosixClock>();
  41. #endif
  42. #ifdef _WIN32
  43. clock = make_shared<WindowsClock>();
  44. #endif
  45. parameter.setClock(clock);
  46. ASSERT_TRUE(parameter.getClock() == clock);
  47. }
  48. }