DateParameterMapperTest.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2023-03-31
  6. * Changed: 2023-03-31
  7. *
  8. * */
  9. #include <gtest/gtest.h>
  10. #include <ls-std/ls-std-time.hpp>
  11. #include <utility>
  12. #include <vector>
  13. using ls::std::time::DateParameter;
  14. using ls::std::time::DateParameterMapper;
  15. using ls::std::time::type::UnixTimestamp;
  16. using std::pair;
  17. using std::vector;
  18. using testing::TestWithParam;
  19. using testing::Values;
  20. namespace
  21. {
  22. class DateParameterMapperTest : public TestWithParam<pair<UnixTimestamp, DateParameter>>
  23. {
  24. public:
  25. DateParameterMapperTest() = default;
  26. ~DateParameterMapperTest() override = default;
  27. static vector<pair<UnixTimestamp, DateParameter>> getTestParameterList()
  28. {
  29. vector<pair<UnixTimestamp, DateParameter>> testParameterList{};
  30. testParameterList.emplace_back(656936700, DateParameter{1990, 10, 26, 11, 25, 00});
  31. testParameterList.emplace_back(612694320, DateParameter{1989, 6, 1, 10, 52, 00});
  32. return testParameterList;
  33. }
  34. };
  35. TEST_P(DateParameterMapperTest, toUnixTimestamp)
  36. {
  37. DateParameter dateParameter = GetParam().second;
  38. UnixTimestamp timestamp = DateParameterMapper::toUnixTimestamp(dateParameter);
  39. ASSERT_EQ(GetParam().first, timestamp);
  40. }
  41. INSTANTIATE_TEST_SUITE_P(toUnixTimestamp, DateParameterMapperTest, Values(DateParameterMapperTest::getTestParameterList().at(0), DateParameterMapperTest::getTestParameterList().at(1)));
  42. }