leapc
Loading...
Searching...
No Matches
leap_date_test.c
1#include "leap.h"
2
3#include <assert.h>
4#include <stdlib.h>
5
6int leap_date_test(int argc, char **argv) {
7 (void)argc;
8 (void)argv;
9
10 assert(equal_leap_date((struct leap_date){1902, 9, 28}, leap_date(1902, 270)));
11 assert(equal_leap_date((struct leap_date){1, 1, 1}, leap_date(1, 0)));
12 assert(equal_leap_date((struct leap_date){2, 1, 1}, leap_date(1, 365)));
13
14 /*
15 * Three hundred and sixty five days from midnight on 1900-01-01 is 1900-12-31
16 * since 1900 is not a leap year.
17 */
18 assert(equal_leap_date((struct leap_date){1900, 12, 31}, leap_date(1900, 364)));
19
20 return EXIT_SUCCESS;
21}
Leap year function prototypes.
struct leap_date leap_date(int year, int day_off)
Date from year and day of year.
Definition leap.c:104
static bool equal_leap_date(struct leap_date lhs, struct leap_date rhs)
Compares two leap_date structures for equality.
Definition leap.h:193
Leap year date structure.
Definition leap.h:163