initial commit
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
#include "timezone_helper.h"
|
||||
#include <gtest/gtest.h>
|
||||
#include <ctime>
|
||||
|
||||
using namespace radiantwave::timezone;
|
||||
|
||||
TEST(TimeZoneTest, GetStandardTimeZonesNonEmpty) {
|
||||
const auto& countries = getStandardTimeZones();
|
||||
EXPECT_FALSE(countries.empty());
|
||||
|
||||
bool found_us = false;
|
||||
bool found_utc = false;
|
||||
|
||||
for (const auto& c : countries) {
|
||||
if (c.country_name == "United States") found_us = true;
|
||||
if (c.country_name == "Coordinated Universal Time") found_utc = true;
|
||||
}
|
||||
|
||||
EXPECT_TRUE(found_us);
|
||||
EXPECT_TRUE(found_utc);
|
||||
}
|
||||
|
||||
TEST(TimeZoneTest, UtcTimestampFormat) {
|
||||
std::string iso = getUtcTimestampIso();
|
||||
EXPECT_FALSE(iso.empty());
|
||||
EXPECT_NE(iso.find("UTC"), std::string::npos);
|
||||
}
|
||||
|
||||
TEST(TimeZoneTest, FormatUtcToTimezone) {
|
||||
// 2026-07-24 12:00:00 UTC
|
||||
// Fixed epoch timestamp: 1784808000
|
||||
time_t fixed_utc = 1784808000;
|
||||
|
||||
std::string formatted_ny = formatUtcToTimezone(fixed_utc, "America/New_York", "%Y-%m-%d %H:%M:%S");
|
||||
std::string formatted_utc = formatUtcToTimezone(fixed_utc, "UTC", "%Y-%m-%d %H:%M:%S");
|
||||
|
||||
EXPECT_FALSE(formatted_ny.empty());
|
||||
EXPECT_EQ(formatted_utc, "2026-07-23 12:00:00");
|
||||
}
|
||||
Reference in New Issue
Block a user