Commit acd6334f authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

Fix Conv.stdChronoToTimespec test on macOS

Summary: [Folly] Fix `Conv.stdChronoToTimespec` test on macOS.

Reviewed By: simpkins

Differential Revision: D14575684

fbshipit-source-id: e0a0dfb89a17eaa5d83e1906f5d92112ab2b5b22
parent dee270d9
......@@ -364,13 +364,18 @@ TEST(Conv, stdChronoToTimespec) {
EXPECT_EQ(36000, ts.tv_sec);
EXPECT_EQ(0, ts.tv_nsec);
ts = to<struct timespec>(createTimePoint<steady_clock>(123ns));
// Must select duration types from the clock for the createTimePoint tests
// since not all clocks on all platforms natively support nanoseconds:
constexpr auto const steady_duration = steady_clock::duration(123);
ts = to<struct timespec>(createTimePoint<steady_clock>(steady_duration));
EXPECT_EQ(0, ts.tv_sec);
EXPECT_EQ(123, ts.tv_nsec);
EXPECT_EQ(nanoseconds(steady_duration).count(), ts.tv_nsec);
ts = to<struct timespec>(createTimePoint<system_clock>(123ns));
constexpr auto const system_duration = system_clock::duration(123);
ts = to<struct timespec>(createTimePoint<system_clock>(system_duration));
EXPECT_EQ(0, ts.tv_sec);
EXPECT_EQ(123, ts.tv_nsec);
EXPECT_EQ(nanoseconds(system_duration).count(), ts.tv_nsec);
// Test with some unusual durations where neither the numerator nor
// denominator are 1.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment