summaryrefslogtreecommitdiff
path: root/absl/time/internal/test_util.cc
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2022-06-14 10:23:06 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2022-06-14 10:24:15 -0700
commit76c7ad82415813cc0354647e4b9b73eaf68a9da0 (patch)
treed5541f04b973a8393be9547627e396a199fc8f1b /absl/time/internal/test_util.cc
parent02b0216656ff68784b4864557cb15b9a554792a4 (diff)
Prefer to fallback to UTC when the embedded zoneinfo data does not
contain the requested zone. And now that we have a fallback at all, remove the special case that allowed for testing absl::LocalTimeZone() under TZ=US/Pacific. And we might as well update the existing embedded data while we're here. This is modifying the test framework only. PiperOrigin-RevId: 454896078 Change-Id: I3ec8391a5a51fe1e86a14f39d57ed6dac89d5905
Diffstat (limited to 'absl/time/internal/test_util.cc')
-rw-r--r--absl/time/internal/test_util.cc21
1 files changed, 6 insertions, 15 deletions
diff --git a/absl/time/internal/test_util.cc b/absl/time/internal/test_util.cc
index 24cff138..454b33a1 100644
--- a/absl/time/internal/test_util.cc
+++ b/absl/time/internal/test_util.cc
@@ -68,10 +68,6 @@ const struct ZoneInfo {
{"Invalid/TimeZone", nullptr, 0},
{"", nullptr, 0},
- // Also allow for loading the local time zone under TZ=US/Pacific.
- {"US/Pacific", //
- reinterpret_cast<char*>(America_Los_Angeles), America_Los_Angeles_len},
-
// Allows use of the local time zone from a system-specific location.
#ifdef _MSC_VER
{"localtime", //
@@ -104,12 +100,6 @@ class TestZoneInfoSource : public cctz::ZoneInfoSource {
const char* const end_;
};
-std::unique_ptr<cctz::ZoneInfoSource> EmbeddedTestZone(const char* data,
- std::size_t size) {
- return std::unique_ptr<cctz::ZoneInfoSource>(
- new TestZoneInfoSource(data, size));
-}
-
std::unique_ptr<cctz::ZoneInfoSource> TestFactory(
const std::string& name,
const std::function<std::unique_ptr<cctz::ZoneInfoSource>(
@@ -117,14 +107,15 @@ std::unique_ptr<cctz::ZoneInfoSource> TestFactory(
for (const ZoneInfo& zoneinfo : kZoneInfo) {
if (name == zoneinfo.name) {
if (zoneinfo.data == nullptr) return nullptr;
- return EmbeddedTestZone(zoneinfo.data, zoneinfo.length);
+ return std::unique_ptr<cctz::ZoneInfoSource>(
+ new TestZoneInfoSource(zoneinfo.data, zoneinfo.length));
}
}
- // The embedded tzdata database knows nothing about this zone. Return
- // something so the tests can proceed.
- return EmbeddedTestZone(reinterpret_cast<char*>(America_Los_Angeles),
- America_Los_Angeles_len);
+ // The embedded zoneinfo data does not include the zone, so fallback to
+ // built-in UTC. The tests have been crafted so that this should only
+ // happen when testing absl::LocalTimeZone() with an unconstrained ${TZ}.
+ return nullptr;
}
} // namespace