summaryrefslogtreecommitdiffstats
path: root/src/log/test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/log/test.cc')
-rw-r--r--src/log/test.cc23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/log/test.cc b/src/log/test.cc
index 6ec9e751b7e..2ae63a741c8 100644
--- a/src/log/test.cc
+++ b/src/log/test.cc
@@ -251,3 +251,26 @@ TEST(Log, TimeSwitch)
log.flush();
log.stop();
}
+
+TEST(Log, TimeFormat)
+{
+ static constexpr auto buflen = 128u;
+ char buf[buflen];
+ ceph::logging::log_clock clock;
+ {
+ clock.coarsen();
+ auto t = clock.now();
+ ceph::logging::append_time(t, buf, buflen);
+ auto c = std::strrchr(buf, '.');
+ ASSERT_NE(c, nullptr);
+ ASSERT_EQ(strlen(c + 1), 3);
+ }
+ {
+ clock.refine();
+ auto t = clock.now();
+ ceph::logging::append_time(t, buf, buflen);
+ auto c = std::strrchr(buf, '.');
+ ASSERT_NE(c, nullptr);
+ ASSERT_EQ(std::strlen(c + 1), 6);
+ }
+}