1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
// SPDX-License-Identifier: BSD-2-Clause
// author: Max Kellermann <max.kellermann@gmail.com>
#include "time/Convert.hxx"
#include <gtest/gtest.h>
static constexpr time_t times[] = {
1234567890,
1580566807,
1585750807,
1590934807,
};
TEST(Time, LocalTime)
{
/* convert back and forth using local time zone */
for (const auto t : times) {
auto tp = std::chrono::system_clock::from_time_t(t);
auto tm = LocalTime(tp);
EXPECT_EQ(MakeTime(tm), tp);
}
}
TEST(Time, GmTime)
{
/* convert back and forth using UTC */
for (const auto t : times) {
auto tp = std::chrono::system_clock::from_time_t(t);
auto tm = GmTime(tp);
EXPECT_EQ(std::chrono::system_clock::to_time_t(TimeGm(tm)),
t);
}
}
|