]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - contrib/ntp/tests/libntp/ymd2yd.c
Upgrade NTP to 4.2.8p4.
[FreeBSD/releng/10.2.git] / contrib / ntp / tests / libntp / ymd2yd.c
1 #include "config.h"
2
3 #include "ntp_stdlib.h"
4
5 #include "unity.h"
6
7 void test_NonLeapYearFebruary(void);
8 void test_NonLeapYearJune(void);
9 void test_LeapYearFebruary(void);
10 void test_LeapYearDecember(void);
11
12
13 void
14 test_NonLeapYearFebruary(void) {
15         TEST_ASSERT_EQUAL(31 + 20, ymd2yd(2010, 2, 20)); //2010-02-20
16 }
17
18
19 void
20 test_NonLeapYearJune(void) {
21         int expected = 31+28+31+30+31+18; // 18 June non-leap year
22         TEST_ASSERT_EQUAL(expected, ymd2yd(2011, 6, 18));
23 }
24
25
26 void
27 test_LeapYearFebruary(void) {
28         TEST_ASSERT_EQUAL(31 + 20, ymd2yd(2012, 2, 20)); //2012-02-20 (leap year)
29 }
30
31
32 void
33 test_LeapYearDecember(void) {
34         // 2012-12-31
35         int expected = 31+29+31+30+31+30+31+31+30+31+30+31;
36         TEST_ASSERT_EQUAL(expected, ymd2yd(2012, 12, 31));
37 }