summaryrefslogtreecommitdiff
path: root/absl/time/time_test.cc
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2023-03-13 17:04:58 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2023-03-13 17:05:47 -0700
commit52578edd8950227f1eb28821622c861804241de6 (patch)
treeb5d91d0b9d53f10e45937cc6c5157c6ae22c683a /absl/time/time_test.cc
parent7f47b00fca75bee477c8a2e3e8fc74a1cf7c743f (diff)
Support AbslStringify in absl::Time and absl::Duration.
PiperOrigin-RevId: 516363556 Change-Id: Iae5e781d46dc8a8c4242ab460b57b65271b93159
Diffstat (limited to 'absl/time/time_test.cc')
-rw-r--r--absl/time/time_test.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/absl/time/time_test.cc b/absl/time/time_test.cc
index d235e9ad..6a89399d 100644
--- a/absl/time/time_test.cc
+++ b/absl/time/time_test.cc
@@ -28,6 +28,7 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "absl/numeric/int128.h"
+#include "absl/strings/str_format.h"
#include "absl/time/clock.h"
#include "absl/time/internal/test_util.h"
@@ -1287,4 +1288,11 @@ TEST(Time, PrevTransitionNYC) {
// We have a transition but we don't know which one.
}
+TEST(Time, AbslStringify) {
+ // FormatTime is already well tested, so just use one test case here to
+ // verify that StrFormat("%v", t) works as expected.
+ absl::Time t = absl::Now();
+ EXPECT_EQ(absl::StrFormat("%v", t), absl::FormatTime(t));
+}
+
} // namespace