4 #include "timevalops.h"
8 void test_Seconds(void);
9 void test_MicrosecondsExact(void);
10 void test_MicrosecondsRounding(void);
15 const l_fp input = {{50}, 0}; /* 50.0 s */
16 const struct timeval expected = {50, 0};
17 struct timeval actual;
19 TSTOTV(&input, &actual);
21 TEST_ASSERT_EQUAL(expected.tv_sec, actual.tv_sec);
22 TEST_ASSERT_EQUAL(expected.tv_usec, actual.tv_usec);
26 test_MicrosecondsExact(void) {
27 const u_long HALF = 2147483648UL;
28 const l_fp input = {{50}, HALF}; /* 50.5 s */
29 const struct timeval expected = {50, 500000};
30 struct timeval actual;
32 TSTOTV(&input, &actual);
34 TEST_ASSERT_EQUAL(expected.tv_sec, actual.tv_sec);
35 TEST_ASSERT_EQUAL(expected.tv_usec, actual.tv_usec);
40 test_MicrosecondsRounding(void) {
41 const l_fp input = {{50}, 3865471UL}; /* Should round to 50.0009 */
42 const struct timeval expected = {50, 900};
43 struct timeval actual;
45 TSTOTV(&input, &actual);
47 TEST_ASSERT_EQUAL(expected.tv_sec, actual.tv_sec);
48 TEST_ASSERT_EQUAL(expected.tv_usec, actual.tv_usec);