X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=tests%2Ftimezone.cpp;fp=tests%2Ftimezone.cpp;h=c59cdd3abcb5874cef3019159be671671807edce;hp=0000000000000000000000000000000000000000;hb=120023d8da0aabcb803a87111608ce84c94661f8;hpb=79482ba7aea1b79c7a310c940cc0292532ef3bcb diff --git a/tests/timezone.cpp b/tests/timezone.cpp new file mode 100644 index 0000000..c59cdd3 --- /dev/null +++ b/tests/timezone.cpp @@ -0,0 +1,48 @@ +#include +#include +#include + +using namespace std; +using namespace Msp; + +class TimeZoneTests: public Test::RegisteredTest +{ +public: + TimeZoneTests(); + + static const char *get_name() { return "TimeZone"; } + +private: + void utc(); + void local(); + void custom(); +}; + + +TimeZoneTests::TimeZoneTests() +{ + add(&TimeZoneTests::utc, "UTC"); + add(&TimeZoneTests::local, "Local"); + add(&TimeZoneTests::custom, "Custom"); +} + +void TimeZoneTests::utc() +{ + Time::TimeZone tz = Time::TimeZone::utc(); + EXPECT_EQUAL(tz.get_name(), "UTC"); + EXPECT_EQUAL(tz.get_offset(), Time::zero); +} + +void TimeZoneTests::local() +{ + Time::TimeZone tz = Time::TimeZone::local(); + info(format("'%s' %s", tz.get_name(), tz.get_offset())); +} + +void TimeZoneTests::custom() +{ + Time::TimeZone tz1(120); + EXPECT_EQUAL(tz1.get_name(), "UTC+2"); + Time::TimeZone tz2(345); + EXPECT_EQUAL(tz2.get_name(), "UTC+5:45"); +}