1/* $NetBSD: ymd2yd.c,v 1.2 2020/05/25 20:47:36 christos Exp $ */ 2 3#include "config.h" 4 5#include "ntp_stdlib.h" 6 7#include "unity.h" 8 9void test_NonLeapYearFebruary(void); 10void test_NonLeapYearJune(void); 11void test_LeapYearFebruary(void); 12void test_LeapYearDecember(void); 13 14 15void 16test_NonLeapYearFebruary(void) { 17 TEST_ASSERT_EQUAL(31 + 20, ymd2yd(2010, 2, 20)); //2010-02-20 18} 19 20 21void 22test_NonLeapYearJune(void) { 23 int expected = 31+28+31+30+31+18; // 18 June non-leap year 24 TEST_ASSERT_EQUAL(expected, ymd2yd(2011, 6, 18)); 25} 26 27 28void 29test_LeapYearFebruary(void) { 30 TEST_ASSERT_EQUAL(31 + 20, ymd2yd(2012, 2, 20)); //2012-02-20 (leap year) 31} 32 33 34void 35test_LeapYearDecember(void) { 36 // 2012-12-31 37 int expected = 31+29+31+30+31+30+31+31+30+31+30+31; 38 TEST_ASSERT_EQUAL(expected, ymd2yd(2012, 12, 31)); 39} 40