diff options
Diffstat (limited to 'contrib/ntp/tests/libntp/clocktime.c')
-rw-r--r-- | contrib/ntp/tests/libntp/clocktime.c | 72 |
1 files changed, 48 insertions, 24 deletions
diff --git a/contrib/ntp/tests/libntp/clocktime.c b/contrib/ntp/tests/libntp/clocktime.c index 67ca401..ed2d4b2 100644 --- a/contrib/ntp/tests/libntp/clocktime.c +++ b/contrib/ntp/tests/libntp/clocktime.c @@ -30,14 +30,18 @@ void test_AlwaysInLimit(void); void setUp() { - ntpcal_set_timefunc(timefunc); - settime(2000, 1, 1, 0, 0, 0); + ntpcal_set_timefunc(timefunc); + settime(2000, 1, 1, 0, 0, 0); + + return; } void tearDown() { - ntpcal_set_timefunc(NULL); + ntpcal_set_timefunc(NULL); + + return; } /* --------------------------------------------------------------------- @@ -45,23 +49,27 @@ tearDown() */ void -test_CurrentYear(void) { +test_CurrentYear(void) +{ /* Timestamp: 2010-06-24 12:50:00Z */ const u_int32 timestamp = 3486372600UL; const u_int32 expected = timestamp; /* exactly the same. */ const int yday=175, hour=12, minute=50, second=0, tzoff=0; - u_long yearstart=0; + u_long yearstart = 0; u_int32 actual; - TEST_ASSERT_TRUE(clocktime(yday, hour, minute, second, tzoff, timestamp, - &yearstart, &actual)); + TEST_ASSERT_TRUE(clocktime(yday, hour, minute, second, tzoff, + timestamp, &yearstart, &actual)); TEST_ASSERT_EQUAL(expected, actual); + + return; } void -test_CurrentYearFuzz(void) { +test_CurrentYearFuzz(void) +{ /* * Timestamp (rec_ui) is: 2010-06-24 12:50:00 * Time sent into function is 12:00:00. @@ -78,13 +86,16 @@ test_CurrentYearFuzz(void) { u_long yearstart=0; u_int32 actual; - TEST_ASSERT_TRUE(clocktime(yday, hour, minute, second, tzoff, timestamp, - &yearstart, &actual)); + TEST_ASSERT_TRUE(clocktime(yday, hour, minute, second, tzoff, + timestamp, &yearstart, &actual)); TEST_ASSERT_EQUAL(expected, actual); + + return; } void -test_TimeZoneOffset(void) { +test_TimeZoneOffset(void) +{ /* * Timestamp (rec_ui) is: 2010-06-24 12:00:00 +0800 * (which is 2010-06-24 04:00:00Z) @@ -105,7 +116,8 @@ test_TimeZoneOffset(void) { } void -test_WrongYearStart(void) { +test_WrongYearStart(void) +{ /* * Timestamp (rec_ui) is: 2010-01-02 11:00:00Z * Time sent into function is 11:00:00. @@ -125,7 +137,8 @@ test_WrongYearStart(void) { } void -test_PreviousYear(void) { +test_PreviousYear(void) +{ /* * Timestamp is: 2010-01-01 01:00:00Z * Time sent into function is 23:00:00 @@ -145,7 +158,8 @@ test_PreviousYear(void) { } void -test_NextYear(void) { +test_NextYear(void) +{ /* * Timestamp is: 2009-12-31 23:00:00Z * Time sent into function is 01:00:00 @@ -158,28 +172,35 @@ test_NextYear(void) { u_long yearstart = 0; u_int32 actual; - TEST_ASSERT_TRUE(clocktime(yday, hour, minute, second, tzoff, timestamp, - &yearstart, &actual)); + TEST_ASSERT_TRUE(clocktime(yday, hour, minute, second, tzoff, + timestamp, &yearstart, &actual)); TEST_ASSERT_EQUAL(expected, actual); + + return; } void -test_NoReasonableConversion(void) { +test_NoReasonableConversion(void) +{ /* Timestamp is: 2010-01-02 11:00:00Z */ const u_int32 timestamp = 3471418800UL; - + const int yday=100, hour=12, minute=0, second=0, tzoff=0; u_long yearstart = 0; u_int32 actual; - TEST_ASSERT_FALSE(clocktime(yday, hour, minute, second, tzoff, timestamp, - &yearstart, &actual)); + TEST_ASSERT_FALSE(clocktime(yday, hour, minute, second, tzoff, + timestamp, &yearstart, &actual)); + + return; } int/*BOOL*/ -isLE(u_int32 diff,u_int32 actual){ - if(diff <= actual){ +isLE(u_int32 diff,u_int32 actual) +{ + + if (diff <= actual) { return TRUE; } else return FALSE; @@ -187,7 +208,8 @@ isLE(u_int32 diff,u_int32 actual){ void -test_AlwaysInLimit(void) { +test_AlwaysInLimit(void) +{ /* Timestamp is: 2010-01-02 11:00:00Z */ const u_int32 timestamp = 3471418800UL; const u_short prime_incs[] = { 127, 151, 163, 179 }; @@ -210,7 +232,8 @@ test_AlwaysInLimit(void) { for (hour = -204; hour < 204; hour += 2) { for (minute = -60; minute < 60; minute++) { clocktime(yday, hour, minute, 30, 0, - timestamp, &yearstart, &actual); + timestamp, &yearstart, + &actual); diff = actual - timestamp; if (diff >= 0x80000000UL) diff = ~diff + 1; @@ -219,4 +242,5 @@ test_AlwaysInLimit(void) { } } } + return; } |