diff options
Diffstat (limited to 'absl/time')
-rw-r--r-- | absl/time/BUILD.bazel | 2 | ||||
-rw-r--r-- | absl/time/format_test.cc | 9 | ||||
-rw-r--r-- | absl/time/internal/test_util.cc | 7 | ||||
-rw-r--r-- | absl/time/internal/test_util.h | 28 | ||||
-rw-r--r-- | absl/time/time.cc | 4 | ||||
-rw-r--r-- | absl/time/time_norm_test.cc | 68 | ||||
-rw-r--r-- | absl/time/time_test.cc | 20 |
7 files changed, 75 insertions, 63 deletions
diff --git a/absl/time/BUILD.bazel b/absl/time/BUILD.bazel index d4f653f..7126f14 100644 --- a/absl/time/BUILD.bazel +++ b/absl/time/BUILD.bazel @@ -51,6 +51,7 @@ cc_library( cc_library( name = "test_util", + testonly = 1, srcs = [ "internal/test_util.cc", "internal/zoneinfo.inc", @@ -64,6 +65,7 @@ cc_library( ":time", "//absl/base", "//absl/time/internal/cctz:time_zone", + "@com_google_googletest//:gtest", ], ) diff --git a/absl/time/format_test.cc b/absl/time/format_test.cc index 09d1fe6..7c84c33 100644 --- a/absl/time/format_test.cc +++ b/absl/time/format_test.cc @@ -155,8 +155,7 @@ TEST(ParseTime, Basics) { "2013-06-28 19:08:09 -0800", &t, &err)) << err; absl::Time::Breakdown bd = t.In(absl::FixedTimeZone(-8 * 60 * 60)); - ABSL_INTERNAL_EXPECT_TIME(bd, 2013, 6, 28, 19, 8, 9, -8 * 60 * 60, false, - "UTC-8"); + ABSL_INTERNAL_EXPECT_TIME(bd, 2013, 6, 28, 19, 8, 9, -8 * 60 * 60, false); EXPECT_EQ(absl::ZeroDuration(), bd.subsecond); } @@ -179,8 +178,7 @@ TEST(ParseTime, WithTimeZone) { absl::ParseTime("%Y-%m-%d %H:%M:%S", "2013-06-28 19:08:09", tz, &t, &e)) << e; absl::Time::Breakdown bd = t.In(tz); - ABSL_INTERNAL_EXPECT_TIME(bd, 2013, 6, 28, 19, 8, 9, -7 * 60 * 60, true, - "PDT"); + ABSL_INTERNAL_EXPECT_TIME(bd, 2013, 6, 28, 19, 8, 9, -7 * 60 * 60, true); EXPECT_EQ(absl::ZeroDuration(), bd.subsecond); // But the timezone is ignored when a UTC offset is present. @@ -188,8 +186,7 @@ TEST(ParseTime, WithTimeZone) { "2013-06-28 19:08:09 +0800", tz, &t, &e)) << e; bd = t.In(absl::FixedTimeZone(8 * 60 * 60)); - ABSL_INTERNAL_EXPECT_TIME(bd, 2013, 6, 28, 19, 8, 9, 8 * 60 * 60, false, - "UTC+8"); + ABSL_INTERNAL_EXPECT_TIME(bd, 2013, 6, 28, 19, 8, 9, 8 * 60 * 60, false); EXPECT_EQ(absl::ZeroDuration(), bd.subsecond); } diff --git a/absl/time/internal/test_util.cc b/absl/time/internal/test_util.cc index 4483f2a..419d859 100644 --- a/absl/time/internal/test_util.cc +++ b/absl/time/internal/test_util.cc @@ -26,6 +26,13 @@ namespace cctz = absl::time_internal::cctz; namespace absl { namespace time_internal { +// TODO(bww): Reinstate when the FixedTimeZone() abbreviations are updated. +#if 1 || GTEST_USES_SIMPLE_RE +extern const char kZoneAbbrRE[] = ".*"; // just punt +#else +extern const char kZoneAbbrRE[] = "[A-Za-z]{3,4}|[-+][0-9]{2}([0-9]{2})?"; +#endif + TimeZone LoadTimeZone(const std::string& name) { TimeZone tz; ABSL_RAW_CHECK(LoadTimeZone(name, &tz), name.c_str()); diff --git a/absl/time/internal/test_util.h b/absl/time/internal/test_util.h index 81a2d29..8fd5fb9 100644 --- a/absl/time/internal/test_util.h +++ b/absl/time/internal/test_util.h @@ -17,6 +17,8 @@ #include <string> +#include "gmock/gmock.h" +#include "gtest/gtest.h" #include "absl/time/time.h" // This helper is a macro so that failed expectations show up with the @@ -24,22 +26,26 @@ // // This is for internal testing of the Base Time library itself. This is not // part of a public API. -#define ABSL_INTERNAL_EXPECT_TIME(bd, y, m, d, h, min, s, off, isdst, zone) \ - do { \ - EXPECT_EQ(y, bd.year); \ - EXPECT_EQ(m, bd.month); \ - EXPECT_EQ(d, bd.day); \ - EXPECT_EQ(h, bd.hour); \ - EXPECT_EQ(min, bd.minute); \ - EXPECT_EQ(s, bd.second); \ - EXPECT_EQ(off, bd.offset); \ - EXPECT_EQ(isdst, bd.is_dst); \ - EXPECT_STREQ(zone, bd.zone_abbr); \ +#define ABSL_INTERNAL_EXPECT_TIME(bd, y, m, d, h, min, s, off, isdst) \ + do { \ + EXPECT_EQ(y, bd.year); \ + EXPECT_EQ(m, bd.month); \ + EXPECT_EQ(d, bd.day); \ + EXPECT_EQ(h, bd.hour); \ + EXPECT_EQ(min, bd.minute); \ + EXPECT_EQ(s, bd.second); \ + EXPECT_EQ(off, bd.offset); \ + EXPECT_EQ(isdst, bd.is_dst); \ + EXPECT_THAT(bd.zone_abbr, \ + testing::MatchesRegex(absl::time_internal::kZoneAbbrRE)); \ } while (0) namespace absl { namespace time_internal { +// A regular expression that matches all zone abbreviations (%Z). +extern const char kZoneAbbrRE[]; + // Loads the named timezone, but dies on any failure. absl::TimeZone LoadTimeZone(const std::string& name); diff --git a/absl/time/time.cc b/absl/time/time.cc index 1dde40d..03720f6 100644 --- a/absl/time/time.cc +++ b/absl/time/time.cc @@ -71,7 +71,7 @@ inline absl::Time::Breakdown InfiniteFutureBreakdown() { bd.yearday = 365; bd.offset = 0; bd.is_dst = false; - bd.zone_abbr = "-0000"; + bd.zone_abbr = "-00"; return bd; } @@ -88,7 +88,7 @@ inline Time::Breakdown InfinitePastBreakdown() { bd.yearday = 1; bd.offset = 0; bd.is_dst = false; - bd.zone_abbr = "-0000"; + bd.zone_abbr = "-00"; return bd; } diff --git a/absl/time/time_norm_test.cc b/absl/time/time_norm_test.cc index 005756e..4436242 100644 --- a/absl/time/time_norm_test.cc +++ b/absl/time/time_norm_test.cc @@ -18,6 +18,7 @@ #include <cstdint> #include <limits> +#include "gmock/gmock.h" #include "gtest/gtest.h" #include "absl/time/internal/test_util.h" #include "absl/time/time.h" @@ -32,31 +33,31 @@ TEST(TimeNormCase, SimpleOverflow) { EXPECT_TRUE(tc.normalized); EXPECT_EQ(absl::TimeConversion::UNIQUE, tc.kind); absl::Time::Breakdown bd = tc.pre.In(utc); - ABSL_INTERNAL_EXPECT_TIME(bd, 2013, 11, 15, 16, 33, 0, 0, false, "UTC"); + ABSL_INTERNAL_EXPECT_TIME(bd, 2013, 11, 15, 16, 33, 0, 0, false); tc = absl::ConvertDateTime(2013, 11, 15, 16, 59 + 1, 14, utc); EXPECT_TRUE(tc.normalized); EXPECT_EQ(absl::TimeConversion::UNIQUE, tc.kind); bd = tc.pre.In(utc); - ABSL_INTERNAL_EXPECT_TIME(bd, 2013, 11, 15, 17, 0, 14, 0, false, "UTC"); + ABSL_INTERNAL_EXPECT_TIME(bd, 2013, 11, 15, 17, 0, 14, 0, false); tc = absl::ConvertDateTime(2013, 11, 15, 23 + 1, 32, 14, utc); EXPECT_TRUE(tc.normalized); EXPECT_EQ(absl::TimeConversion::UNIQUE, tc.kind); bd = tc.pre.In(utc); - ABSL_INTERNAL_EXPECT_TIME(bd, 2013, 11, 16, 0, 32, 14, 0, false, "UTC"); + ABSL_INTERNAL_EXPECT_TIME(bd, 2013, 11, 16, 0, 32, 14, 0, false); tc = absl::ConvertDateTime(2013, 11, 30 + 1, 16, 32, 14, utc); EXPECT_TRUE(tc.normalized); EXPECT_EQ(absl::TimeConversion::UNIQUE, tc.kind); bd = tc.pre.In(utc); - ABSL_INTERNAL_EXPECT_TIME(bd, 2013, 12, 1, 16, 32, 14, 0, false, "UTC"); + ABSL_INTERNAL_EXPECT_TIME(bd, 2013, 12, 1, 16, 32, 14, 0, false); tc = absl::ConvertDateTime(2013, 12 + 1, 15, 16, 32, 14, utc); EXPECT_TRUE(tc.normalized); EXPECT_EQ(absl::TimeConversion::UNIQUE, tc.kind); bd = tc.pre.In(utc); - ABSL_INTERNAL_EXPECT_TIME(bd, 2014, 1, 15, 16, 32, 14, 0, false, "UTC"); + ABSL_INTERNAL_EXPECT_TIME(bd, 2014, 1, 15, 16, 32, 14, 0, false); } TEST(TimeNormCase, SimpleUnderflow) { @@ -66,31 +67,31 @@ TEST(TimeNormCase, SimpleUnderflow) { EXPECT_TRUE(tc.normalized); EXPECT_EQ(absl::TimeConversion::UNIQUE, tc.kind); absl::Time::Breakdown bd = tc.pre.In(utc); - ABSL_INTERNAL_EXPECT_TIME(bd, 2013, 11, 15, 16, 31, 59, 0, false, "UTC"); + ABSL_INTERNAL_EXPECT_TIME(bd, 2013, 11, 15, 16, 31, 59, 0, false); tc = ConvertDateTime(2013, 11, 15, 16, 0 - 1, 14, utc); EXPECT_TRUE(tc.normalized); EXPECT_EQ(absl::TimeConversion::UNIQUE, tc.kind); bd = tc.pre.In(utc); - ABSL_INTERNAL_EXPECT_TIME(bd, 2013, 11, 15, 15, 59, 14, 0, false, "UTC"); + ABSL_INTERNAL_EXPECT_TIME(bd, 2013, 11, 15, 15, 59, 14, 0, false); tc = ConvertDateTime(2013, 11, 15, 0 - 1, 32, 14, utc); EXPECT_TRUE(tc.normalized); EXPECT_EQ(absl::TimeConversion::UNIQUE, tc.kind); bd = tc.pre.In(utc); - ABSL_INTERNAL_EXPECT_TIME(bd, 2013, 11, 14, 23, 32, 14, 0, false, "UTC"); + ABSL_INTERNAL_EXPECT_TIME(bd, 2013, 11, 14, 23, 32, 14, 0, false); tc = ConvertDateTime(2013, 11, 1 - 1, 16, 32, 14, utc); EXPECT_TRUE(tc.normalized); EXPECT_EQ(absl::TimeConversion::UNIQUE, tc.kind); bd = tc.pre.In(utc); - ABSL_INTERNAL_EXPECT_TIME(bd, 2013, 10, 31, 16, 32, 14, 0, false, "UTC"); + ABSL_INTERNAL_EXPECT_TIME(bd, 2013, 10, 31, 16, 32, 14, 0, false); tc = ConvertDateTime(2013, 1 - 1, 15, 16, 32, 14, utc); EXPECT_TRUE(tc.normalized); EXPECT_EQ(absl::TimeConversion::UNIQUE, tc.kind); bd = tc.pre.In(utc); - ABSL_INTERNAL_EXPECT_TIME(bd, 2012, 12, 15, 16, 32, 14, 0, false, "UTC"); + ABSL_INTERNAL_EXPECT_TIME(bd, 2012, 12, 15, 16, 32, 14, 0, false); } TEST(TimeNormCase, MultipleOverflow) { @@ -99,7 +100,7 @@ TEST(TimeNormCase, MultipleOverflow) { EXPECT_TRUE(tc.normalized); EXPECT_EQ(absl::TimeConversion::UNIQUE, tc.kind); absl::Time::Breakdown bd = tc.pre.In(utc); - ABSL_INTERNAL_EXPECT_TIME(bd, 2014, 1, 1, 0, 0, 0, 0, false, "UTC"); + ABSL_INTERNAL_EXPECT_TIME(bd, 2014, 1, 1, 0, 0, 0, 0, false); } TEST(TimeNormCase, MultipleUnderflow) { @@ -108,7 +109,7 @@ TEST(TimeNormCase, MultipleUnderflow) { EXPECT_TRUE(tc.normalized); EXPECT_EQ(absl::TimeConversion::UNIQUE, tc.kind); absl::Time::Breakdown bd = tc.pre.In(utc); - ABSL_INTERNAL_EXPECT_TIME(bd, 2013, 12, 31, 23, 59, 59, 0, false, "UTC"); + ABSL_INTERNAL_EXPECT_TIME(bd, 2013, 12, 31, 23, 59, 59, 0, false); } TEST(TimeNormCase, OverflowLimits) { @@ -122,7 +123,7 @@ TEST(TimeNormCase, OverflowLimits) { EXPECT_TRUE(tc.normalized); EXPECT_EQ(absl::TimeConversion::UNIQUE, tc.kind); bd = tc.pre.In(utc); - ABSL_INTERNAL_EXPECT_TIME(bd, 185085715, 11, 27, 12, 21, 7, 0, false, "UTC"); + ABSL_INTERNAL_EXPECT_TIME(bd, 185085715, 11, 27, 12, 21, 7, 0, false); const int kintmin = std::numeric_limits<int>::min(); tc = absl::ConvertDateTime(0, kintmin, kintmin, kintmin, kintmin, kintmin, @@ -130,8 +131,7 @@ TEST(TimeNormCase, OverflowLimits) { EXPECT_TRUE(tc.normalized); EXPECT_EQ(absl::TimeConversion::UNIQUE, tc.kind); bd = tc.pre.In(utc); - ABSL_INTERNAL_EXPECT_TIME(bd, -185085717, 10, 31, 10, 37, 52, 0, false, - "UTC"); + ABSL_INTERNAL_EXPECT_TIME(bd, -185085717, 10, 31, 10, 37, 52, 0, false); const int64_t max_year = std::numeric_limits<int64_t>::max(); tc = absl::ConvertDateTime(max_year, 12, 31, 23, 59, 59, utc); @@ -154,31 +154,31 @@ TEST(TimeNormCase, ComplexOverflow) { EXPECT_TRUE(tc.normalized); EXPECT_EQ(absl::TimeConversion::UNIQUE, tc.kind); absl::Time::Breakdown bd = tc.pre.In(utc); - ABSL_INTERNAL_EXPECT_TIME(bd, 2017, 10, 14, 14, 5, 23, 0, false, "UTC"); + ABSL_INTERNAL_EXPECT_TIME(bd, 2017, 10, 14, 14, 5, 23, 0, false); tc = absl::ConvertDateTime(2013, 11, 15, 16, 32 + 1234567, 14, utc); EXPECT_TRUE(tc.normalized); EXPECT_EQ(absl::TimeConversion::UNIQUE, tc.kind); bd = tc.pre.In(utc); - ABSL_INTERNAL_EXPECT_TIME(bd, 2016, 3, 22, 0, 39, 14, 0, false, "UTC"); + ABSL_INTERNAL_EXPECT_TIME(bd, 2016, 3, 22, 0, 39, 14, 0, false); tc = absl::ConvertDateTime(2013, 11, 15, 16 + 123456, 32, 14, utc); EXPECT_TRUE(tc.normalized); EXPECT_EQ(absl::TimeConversion::UNIQUE, tc.kind); bd = tc.pre.In(utc); - ABSL_INTERNAL_EXPECT_TIME(bd, 2027, 12, 16, 16, 32, 14, 0, false, "UTC"); + ABSL_INTERNAL_EXPECT_TIME(bd, 2027, 12, 16, 16, 32, 14, 0, false); tc = absl::ConvertDateTime(2013, 11, 15 + 1234, 16, 32, 14, utc); EXPECT_TRUE(tc.normalized); EXPECT_EQ(absl::TimeConversion::UNIQUE, tc.kind); bd = tc.pre.In(utc); - ABSL_INTERNAL_EXPECT_TIME(bd, 2017, 4, 2, 16, 32, 14, 0, false, "UTC"); + ABSL_INTERNAL_EXPECT_TIME(bd, 2017, 4, 2, 16, 32, 14, 0, false); tc = absl::ConvertDateTime(2013, 11 + 123, 15, 16, 32, 14, utc); EXPECT_TRUE(tc.normalized); EXPECT_EQ(absl::TimeConversion::UNIQUE, tc.kind); bd = tc.pre.In(utc); - ABSL_INTERNAL_EXPECT_TIME(bd, 2024, 2, 15, 16, 32, 14, 0, false, "UTC"); + ABSL_INTERNAL_EXPECT_TIME(bd, 2024, 2, 15, 16, 32, 14, 0, false); } TEST(TimeNormCase, ComplexUnderflow) { @@ -189,37 +189,37 @@ TEST(TimeNormCase, ComplexUnderflow) { EXPECT_TRUE(tc.normalized); EXPECT_EQ(absl::TimeConversion::UNIQUE, tc.kind); absl::Time::Breakdown bd = tc.pre.In(utc); - ABSL_INTERNAL_EXPECT_TIME(bd, 1999, 2, 28, 0, 0, 0, 0, false, "UTC"); + ABSL_INTERNAL_EXPECT_TIME(bd, 1999, 2, 28, 0, 0, 0, 0, false); tc = absl::ConvertDateTime(2013, 11, 15, 16, 32, 14 - 123456789, utc); EXPECT_TRUE(tc.normalized); EXPECT_EQ(absl::TimeConversion::UNIQUE, tc.kind); bd = tc.pre.In(utc); - ABSL_INTERNAL_EXPECT_TIME(bd, 2009, 12, 17, 18, 59, 5, 0, false, "UTC"); + ABSL_INTERNAL_EXPECT_TIME(bd, 2009, 12, 17, 18, 59, 5, 0, false); tc = absl::ConvertDateTime(2013, 11, 15, 16, 32 - 1234567, 14, utc); EXPECT_TRUE(tc.normalized); EXPECT_EQ(absl::TimeConversion::UNIQUE, tc.kind); bd = tc.pre.In(utc); - ABSL_INTERNAL_EXPECT_TIME(bd, 2011, 7, 12, 8, 25, 14, 0, false, "UTC"); + ABSL_INTERNAL_EXPECT_TIME(bd, 2011, 7, 12, 8, 25, 14, 0, false); tc = absl::ConvertDateTime(2013, 11, 15, 16 - 123456, 32, 14, utc); EXPECT_TRUE(tc.normalized); EXPECT_EQ(absl::TimeConversion::UNIQUE, tc.kind); bd = tc.pre.In(utc); - ABSL_INTERNAL_EXPECT_TIME(bd, 1999, 10, 16, 16, 32, 14, 0, false, "UTC"); + ABSL_INTERNAL_EXPECT_TIME(bd, 1999, 10, 16, 16, 32, 14, 0, false); tc = absl::ConvertDateTime(2013, 11, 15 - 1234, 16, 32, 14, utc); EXPECT_TRUE(tc.normalized); EXPECT_EQ(absl::TimeConversion::UNIQUE, tc.kind); bd = tc.pre.In(utc); - ABSL_INTERNAL_EXPECT_TIME(bd, 2010, 6, 30, 16, 32, 14, 0, false, "UTC"); + ABSL_INTERNAL_EXPECT_TIME(bd, 2010, 6, 30, 16, 32, 14, 0, false); tc = absl::ConvertDateTime(2013, 11 - 123, 15, 16, 32, 14, utc); EXPECT_TRUE(tc.normalized); EXPECT_EQ(absl::TimeConversion::UNIQUE, tc.kind); bd = tc.pre.In(utc); - ABSL_INTERNAL_EXPECT_TIME(bd, 2003, 8, 15, 16, 32, 14, 0, false, "UTC"); + ABSL_INTERNAL_EXPECT_TIME(bd, 2003, 8, 15, 16, 32, 14, 0, false); } TEST(TimeNormCase, Mishmash) { @@ -231,14 +231,14 @@ TEST(TimeNormCase, Mishmash) { EXPECT_TRUE(tc.normalized); EXPECT_EQ(absl::TimeConversion::UNIQUE, tc.kind); absl::Time::Breakdown bd = tc.pre.In(utc); - ABSL_INTERNAL_EXPECT_TIME(bd, 1991, 5, 9, 3, 6, 5, 0, false, "UTC"); + ABSL_INTERNAL_EXPECT_TIME(bd, 1991, 5, 9, 3, 6, 5, 0, false); tc = absl::ConvertDateTime(2013, 11 + 123, 15 - 1234, 16 + 123456, 32 - 1234567, 14 + 123456789, utc); EXPECT_TRUE(tc.normalized); EXPECT_EQ(absl::TimeConversion::UNIQUE, tc.kind); bd = tc.pre.In(utc); - ABSL_INTERNAL_EXPECT_TIME(bd, 2036, 5, 24, 5, 58, 23, 0, false, "UTC"); + ABSL_INTERNAL_EXPECT_TIME(bd, 2036, 5, 24, 5, 58, 23, 0, false); // Here is a normalization case we got wrong for a while. Because the // day is converted to "1" within a 400-year (146097-day) period, we @@ -247,7 +247,7 @@ TEST(TimeNormCase, Mishmash) { EXPECT_TRUE(tc.normalized); EXPECT_EQ(absl::TimeConversion::UNIQUE, tc.kind); bd = tc.pre.In(utc); - ABSL_INTERNAL_EXPECT_TIME(bd, 1613, 11, 1, 16, 32, 14, 0, false, "UTC"); + ABSL_INTERNAL_EXPECT_TIME(bd, 1613, 11, 1, 16, 32, 14, 0, false); // Even though the month overflow compensates for the day underflow, // this should still be marked as normalized. @@ -255,7 +255,7 @@ TEST(TimeNormCase, Mishmash) { EXPECT_TRUE(tc.normalized); EXPECT_EQ(absl::TimeConversion::UNIQUE, tc.kind); bd = tc.pre.In(utc); - ABSL_INTERNAL_EXPECT_TIME(bd, 2013, 11, 1, 16, 32, 14, 0, false, "UTC"); + ABSL_INTERNAL_EXPECT_TIME(bd, 2013, 11, 1, 16, 32, 14, 0, false); } TEST(TimeNormCase, LeapYears) { @@ -266,25 +266,25 @@ TEST(TimeNormCase, LeapYears) { EXPECT_TRUE(tc.normalized); EXPECT_EQ(absl::TimeConversion::UNIQUE, tc.kind); absl::Time::Breakdown bd = tc.pre.In(utc); - ABSL_INTERNAL_EXPECT_TIME(bd, 2013, 3, 1, 0, 0, 0, 0, false, "UTC"); + ABSL_INTERNAL_EXPECT_TIME(bd, 2013, 3, 1, 0, 0, 0, 0, false); tc = absl::ConvertDateTime(2012, 2, 28 + 1, 0, 0, 0, utc); EXPECT_FALSE(tc.normalized); EXPECT_EQ(absl::TimeConversion::UNIQUE, tc.kind); bd = tc.pre.In(utc); - ABSL_INTERNAL_EXPECT_TIME(bd, 2012, 2, 29, 0, 0, 0, 0, false, "UTC"); + ABSL_INTERNAL_EXPECT_TIME(bd, 2012, 2, 29, 0, 0, 0, 0, false); tc = absl::ConvertDateTime(2000, 2, 28 + 1, 0, 0, 0, utc); EXPECT_FALSE(tc.normalized); EXPECT_EQ(absl::TimeConversion::UNIQUE, tc.kind); bd = tc.pre.In(utc); - ABSL_INTERNAL_EXPECT_TIME(bd, 2000, 2, 29, 0, 0, 0, 0, false, "UTC"); + ABSL_INTERNAL_EXPECT_TIME(bd, 2000, 2, 29, 0, 0, 0, 0, false); tc = absl::ConvertDateTime(1900, 2, 28 + 1, 0, 0, 0, utc); EXPECT_TRUE(tc.normalized); EXPECT_EQ(absl::TimeConversion::UNIQUE, tc.kind); bd = tc.pre.In(utc); - ABSL_INTERNAL_EXPECT_TIME(bd, 1900, 3, 1, 0, 0, 0, 0, false, "UTC"); + ABSL_INTERNAL_EXPECT_TIME(bd, 1900, 3, 1, 0, 0, 0, 0, false); } // Convert all the days from 1970-1-1 to 1970-1-146097 (aka 2369-12-31) diff --git a/absl/time/time_test.cc b/absl/time/time_test.cc index 6408388..4f8f58a 100644 --- a/absl/time/time_test.cc +++ b/absl/time/time_test.cc @@ -85,7 +85,7 @@ TEST(Time, ValueSemantics) { TEST(Time, UnixEpoch) { absl::Time::Breakdown bd = absl::UnixEpoch().In(absl::UTCTimeZone()); - ABSL_INTERNAL_EXPECT_TIME(bd, 1970, 1, 1, 0, 0, 0, 0, false, "UTC"); + ABSL_INTERNAL_EXPECT_TIME(bd, 1970, 1, 1, 0, 0, 0, 0, false); EXPECT_EQ(absl::ZeroDuration(), bd.subsecond); EXPECT_EQ(4, bd.weekday); // Thursday } @@ -96,14 +96,14 @@ TEST(Time, Breakdown) { // The Unix epoch as seen in NYC. absl::Time::Breakdown bd = t.In(tz); - ABSL_INTERNAL_EXPECT_TIME(bd, 1969, 12, 31, 19, 0, 0, -18000, false, "EST"); + ABSL_INTERNAL_EXPECT_TIME(bd, 1969, 12, 31, 19, 0, 0, -18000, false); EXPECT_EQ(absl::ZeroDuration(), bd.subsecond); EXPECT_EQ(3, bd.weekday); // Wednesday // Just before the epoch. t -= absl::Nanoseconds(1); bd = t.In(tz); - ABSL_INTERNAL_EXPECT_TIME(bd, 1969, 12, 31, 18, 59, 59, -18000, false, "EST"); + ABSL_INTERNAL_EXPECT_TIME(bd, 1969, 12, 31, 18, 59, 59, -18000, false); EXPECT_EQ(absl::Nanoseconds(999999999), bd.subsecond); EXPECT_EQ(3, bd.weekday); // Wednesday @@ -112,7 +112,7 @@ TEST(Time, Breakdown) { t += absl::Hours(18) + absl::Minutes(30) + absl::Seconds(15) + absl::Nanoseconds(9); bd = t.In(tz); - ABSL_INTERNAL_EXPECT_TIME(bd, 1977, 6, 28, 14, 30, 15, -14400, true, "EDT"); + ABSL_INTERNAL_EXPECT_TIME(bd, 1977, 6, 28, 14, 30, 15, -14400, true); EXPECT_EQ(8, bd.subsecond / absl::Nanoseconds(1)); EXPECT_EQ(2, bd.weekday); // Tuesday } @@ -983,16 +983,18 @@ TEST(Time, ConversionSaturation) { // Checks how Time::In() saturates on infinities. absl::Time::Breakdown bd = absl::InfiniteFuture().In(utc); ABSL_INTERNAL_EXPECT_TIME(bd, std::numeric_limits<int64_t>::max(), 12, 31, 23, - 59, 59, 0, false, "-0000"); + 59, 59, 0, false); EXPECT_EQ(absl::InfiniteDuration(), bd.subsecond); EXPECT_EQ(4, bd.weekday); // Thursday EXPECT_EQ(365, bd.yearday); + EXPECT_STREQ("-00", bd.zone_abbr); // artifact of absl::Time::In() bd = absl::InfinitePast().In(utc); ABSL_INTERNAL_EXPECT_TIME(bd, std::numeric_limits<int64_t>::min(), 1, 1, 0, 0, - 0, 0, false, "-0000"); + 0, 0, false); EXPECT_EQ(-absl::InfiniteDuration(), bd.subsecond); EXPECT_EQ(7, bd.weekday); // Sunday EXPECT_EQ(1, bd.yearday); + EXPECT_STREQ("-00", bd.zone_abbr); // artifact of absl::Time::In() // Approach the maximal Time value from below. t = absl::FromDateTime(292277026596, 12, 4, 15, 30, 6, utc); @@ -1054,13 +1056,11 @@ TEST(Time, ExtendedConversionSaturation) { // The maximal time converted in each zone. bd = max.In(syd); - ABSL_INTERNAL_EXPECT_TIME(bd, 292277026596, 12, 5, 2, 30, 7, 39600, true, - "AEDT"); + ABSL_INTERNAL_EXPECT_TIME(bd, 292277026596, 12, 5, 2, 30, 7, 39600, true); t = absl::FromDateTime(292277026596, 12, 5, 2, 30, 7, syd); EXPECT_EQ(max, t); bd = max.In(nyc); - ABSL_INTERNAL_EXPECT_TIME(bd, 292277026596, 12, 4, 10, 30, 7, -18000, false, - "EST"); + ABSL_INTERNAL_EXPECT_TIME(bd, 292277026596, 12, 4, 10, 30, 7, -18000, false); t = absl::FromDateTime(292277026596, 12, 4, 10, 30, 7, nyc); EXPECT_EQ(max, t); |