From 6232d13f5321b87ddf12a1aa36b4545da45f173d Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Wed, 17 Nov 2021 22:34:57 +0100 Subject: Travel3: Simple image and video display site Reads the images and videos from filesystem and builds a site in memroy. --- test/test_tz_str.cc | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 test/test_tz_str.cc (limited to 'test/test_tz_str.cc') diff --git a/test/test_tz_str.cc b/test/test_tz_str.cc new file mode 100644 index 0000000..a96c4ea --- /dev/null +++ b/test/test_tz_str.cc @@ -0,0 +1,97 @@ +#include "common.hh" + +#include "tz_str.hh" + +#include + +namespace { + +constexpr const time_t kMin = 60; +constexpr const time_t kHour = 60 * kMin; +constexpr const time_t kDay = 24 * kHour; + +} // namespace + +TEST(tz_str, get_local_time_no_dst) { + auto ret = tz::get_local_time("HST10", 0); + EXPECT_TRUE(ret.has_value()); + if (ret.has_value()) { + EXPECT_EQ(0 - 10 * kHour, ret.value()); + } + + ret = tz::get_local_time("HST10", kDay * 180); + EXPECT_TRUE(ret.has_value()); + if (ret.has_value()) { + EXPECT_EQ(kDay * 180 - 10 * kHour, ret.value()); + } +} + +TEST(tz_str, get_local_time_quote) { + auto ret = tz::get_local_time("10", 0); + EXPECT_TRUE(ret.has_value()); + if (ret.has_value()) { + EXPECT_EQ(0 - 10 * kHour, ret.value()); + } +} + +TEST(tz_str, get_local_time_dst) { + auto ret = tz::get_local_time("IST-1GMT0,M10.5.0,M3.5.0/1", 0); + EXPECT_TRUE(ret.has_value()); + if (ret.has_value()) { + EXPECT_EQ(0 * kHour, ret.value()); + } + + ret = tz::get_local_time("IST-1GMT0,M10.5.0,M3.5.0/1", kDay * 180); + EXPECT_TRUE(ret.has_value()); + if (ret.has_value()) { + EXPECT_EQ(kDay * 180 + 1 * kHour, ret.value()); + } + + ret = tz::get_local_time("GMT0IST,M3.5.0/1,M10.5.0", 0); + EXPECT_TRUE(ret.has_value()); + if (ret.has_value()) { + EXPECT_EQ(0 * kHour, ret.value()); + } + + ret = tz::get_local_time("GMT0IST,M3.5.0/1,M10.5.0", kDay * 180); + EXPECT_TRUE(ret.has_value()); + if (ret.has_value()) { + EXPECT_EQ(kDay * 180 + 1 * kHour, ret.value()); + } + + ret = tz::get_local_time("NZST-12:00:00NZDT-13:00:00,M10.1.0,M3.3.0", 0); + EXPECT_TRUE(ret.has_value()); + if (ret.has_value()) { + EXPECT_EQ(13 * kHour, ret.value()); + } + + ret = tz::get_local_time("NZST-12:00:00NZDT-13:00:00,M10.1.0,M3.3.0", + kDay * 180); + EXPECT_TRUE(ret.has_value()); + if (ret.has_value()) { + EXPECT_EQ(kDay * 180 + 12 * kHour, ret.value()); + } +} + +TEST(tz_str, get_local_time_bad) { + auto ret = tz::get_local_time("1", 0); + EXPECT_FALSE(ret.has_value()); + + ret = tz::get_local_time("HS10", 0); + EXPECT_FALSE(ret.has_value()); + + ret = tz::get_local_time("HST", 0); + EXPECT_FALSE(ret.has_value()); + + ret = tz::get_local_time("HST-300", 0); + EXPECT_FALSE(ret.has_value()); + + ret = tz::get_local_time("HST-10:300", 0); + EXPECT_FALSE(ret.has_value()); + + ret = tz::get_local_time("HST-10:00:300", 0); + EXPECT_FALSE(ret.has_value()); +} -- cgit v1.2.3-70-g09d2