39 #include <gtest/gtest.h>
43 TEST(Construction, default_)
51 TEST(Construction, second_microsecond)
53 for (
volatile int32_t sec = -1000000; sec <= 1000000; sec += 100000)
55 for (
volatile int32_t usec = -1000000; usec <= 1100000; usec += 10000)
60 sec * 1000000 + usec);
62 if (usec >= 0 && usec < 1000000)
71 TEST(Construction, timeval)
73 for (
volatile int32_t sec = -1000000; sec <= 1000000; sec += 100000)
75 for (
volatile int32_t usec = -1000000; usec <= 1100000; usec += 10000)
84 sec * 1000000 + usec);
86 if (usec >= 0 && usec < 1000000)
95 TEST(Construction, nanoseconds)
98 for (
volatile int64_t sec = -1000000; sec <= 1000000; sec += 100000)
100 for (
volatile int64_t usec = -1000000; usec <= 1100000; usec += 10000)
102 const int64_t nsec = sec * 1000000000 + usec * 1000;
107 sec * 1000000 + usec);
109 if (usec >= 0 && usec < 1000000)
120 TEST(GetNanoSeconds, getNanoSeconds)
125 for (
volatile int64_t nsec = -100000000000; nsec <= 100000000000; nsec += 100000000)
136 const int64_t max_nsec = 10000000000;
137 const int64_t step_nsec = 100000000;
138 for (
volatile int64_t a_nsec = -max_nsec; a_nsec <= max_nsec; a_nsec += step_nsec)
140 for (
volatile int64_t b_nsec = -max_nsec; b_nsec <= max_nsec; b_nsec += step_nsec)
145 EXPECT_EQ((a + b).getNanoSeconds(), a_nsec + b_nsec);
154 const int64_t max_nsec = 10000000000;
155 const int64_t step_nsec = 100000000;
156 for (
volatile int64_t a_nsec = -max_nsec; a_nsec <= max_nsec; a_nsec += step_nsec)
158 for (
volatile int64_t b_nsec = -max_nsec; b_nsec <= max_nsec; b_nsec += step_nsec)
163 EXPECT_EQ((a - b).getNanoSeconds(), a_nsec - b_nsec);