calyearstart.c revision 289999
1#include "config.h" 2 3#include "ntp_stdlib.h" 4#include "ntp_calendar.h" 5#include "unity.h" 6 7#include "test-libntp.h" 8 9void setUp(void); 10void tearDown(void); 11void test_NoWrapInDateRange(void); 12void test_NoWrapInDateRangeLeapYear(void); 13void test_WrapInDateRange(void); 14 15void setUp(void) 16{ 17 ntpcal_set_timefunc(timefunc); 18 settime(1970, 1, 1, 0, 0, 0); 19} 20 21void tearDown(void) 22{ 23 ntpcal_set_timefunc(NULL); 24} 25 26 27void test_NoWrapInDateRange(void) { 28 const u_int32 input = 3486372600UL; // 2010-06-24 12:50:00. 29 const u_int32 expected = 3471292800UL; // 2010-01-01 00:00:00 30 31 TEST_ASSERT_EQUAL(expected, calyearstart(input, &nowtime)); 32 TEST_ASSERT_EQUAL(expected, calyearstart(input, NULL)); 33} 34 35void test_NoWrapInDateRangeLeapYear(void) { 36 const u_int32 input = 3549528000UL; // 2012-06-24 12:00:00 37 const u_int32 expected = 3534364800UL; // 2012-01-01 00:00:00 38 39 TEST_ASSERT_EQUAL(expected, calyearstart(input, &nowtime)); 40 TEST_ASSERT_EQUAL(expected, calyearstart(input, NULL)); 41} 42 43void test_WrapInDateRange(void) { 44 const u_int32 input = 19904UL; // 2036-02-07 12:00:00 45 const u_int32 expected = 4291747200UL; // 2036-01-01 00:00:00 46 47 TEST_ASSERT_EQUAL(expected, calyearstart(input, &nowtime)); 48 TEST_ASSERT_EQUAL(expected, calyearstart(input, NULL)); 49} 50