Files
comaps/base/base_tests/timegm_test.cpp
Konstantin Pastbin e3e4a1985a Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run:
  git remote add om-historic [om-historic.git repo url]
  git fetch --tags om-historic
  git replace squashed-history historic-commits
2025-05-08 21:10:51 +07:00

32 lines
1.1 KiB
C++

#include "testing/testing.hpp"
#include <ctime>
#include "base/timegm.hpp"
UNIT_TEST(TimegmTest)
{
std::tm tm1{};
std::tm tm2{};
TEST(strptime("2016-05-17 07:10", "%Y-%m-%d %H:%M", &tm1), ());
TEST(strptime("2016-05-17 07:10", "%Y-%m-%d %H:%M", &tm2), ());
TEST_EQUAL(timegm(&tm1), base::TimeGM(tm2), ());
TEST_EQUAL(timegm(&tm1), base::TimeGM(2016, 5, 17, 7, 10, 0), ());
TEST(strptime("2016-03-12 11:10", "%Y-%m-%d %H:%M", &tm1), ());
TEST(strptime("2016-03-12 11:10", "%Y-%m-%d %H:%M", &tm2), ());
TEST_EQUAL(timegm(&tm1), base::TimeGM(tm2), ());
TEST_EQUAL(timegm(&tm1), base::TimeGM(2016, 3, 12, 11, 10, 0), ());
TEST(strptime("1970-01-01 00:00", "%Y-%m-%d %H:%M", &tm1), ());
TEST(strptime("1970-01-01 00:00", "%Y-%m-%d %H:%M", &tm2), ());
TEST_EQUAL(timegm(&tm1), base::TimeGM(tm2), ());
TEST_EQUAL(timegm(&tm1), base::TimeGM(1970, 1, 1, 0, 0, 0), ());
TEST(strptime("2012-12-02 21:08:34", "%Y-%m-%d %H:%M:%S", &tm1), ());
TEST(strptime("2012-12-02 21:08:34", "%Y-%m-%d %H:%M:%S", &tm2), ());
TEST_EQUAL(timegm(&tm1), base::TimeGM(tm2), ());
TEST_EQUAL(timegm(&tm1), base::TimeGM(2012, 12, 2, 21, 8, 34), ());
}