4 #include "timevalops.h"
10 const l_fp input = {50, 0}; // 50.0 s
11 const struct timeval expected = {50, 0};
12 struct timeval actual;
14 TSTOTV(&input, &actual);
16 TEST_ASSERT_EQUAL(expected.tv_sec, actual.tv_sec);
17 TEST_ASSERT_EQUAL(expected.tv_usec, actual.tv_usec);
21 test_MicrosecondsExact(void) {
22 const u_long HALF = 2147483648UL;
23 const l_fp input = {50, HALF}; // 50.5 s
24 const struct timeval expected = {50, 500000};
25 struct timeval actual;
27 TSTOTV(&input, &actual);
29 TEST_ASSERT_EQUAL(expected.tv_sec, actual.tv_sec);
30 TEST_ASSERT_EQUAL(expected.tv_usec, actual.tv_usec);
35 test_MicrosecondsRounding(void) {
36 const l_fp input = {50, 3865471UL}; // Should round to 50.0009
37 const struct timeval expected = {50, 900};
38 struct timeval actual;
40 TSTOTV(&input, &actual);
42 TEST_ASSERT_EQUAL(expected.tv_sec, actual.tv_sec);
43 TEST_ASSERT_EQUAL(expected.tv_usec, actual.tv_usec);