10int leap_helpers_test(
int argc,
char **argv) {
14 static const struct leap_off offsets[] = {
26 for (
size_t i = 0; i <
sizeof offsets /
sizeof offsets[0]; i++)
27 for (
size_t j = 0; j <
sizeof offsets /
sizeof offsets[0]; j++)
30 for (
size_t i = 0; i <
sizeof dates /
sizeof dates[0]; i++)
31 for (
size_t j = 0; j <
sizeof dates /
sizeof dates[0]; j++)
40 {{0, 1, 1}, {0, 0}, 0}, {{0, 2, 29}, {0, 59}, 59}, {{0, 12, 31}, {0, 365}, 365},
41 {{1, 1, 1}, {1, 0}, 366}, {{-1, 12, 31}, {-1, 364}, -1},
44 for (
size_t i = 0; i <
sizeof cases /
sizeof cases[0]; i++) {
46 assert(off.
year == cases[i].off.year);
47 assert(off.
day == cases[i].off.day);
51 assert(date.
year == cases[i].date.year);
52 assert(date.
month == cases[i].date.month);
53 assert(date.
day == cases[i].date.day);
Leap year function prototypes.
static bool equal_leap_off(struct leap_off lhs, struct leap_off rhs)
Compares two leap_off structures for equality.
static int leap_abs_from_date(struct leap_date date)
Absolute date from leap_date structure.
static struct leap_date leap_date_from_off(struct leap_off off)
Date from leap offset.
struct leap_date leap_date(int year, int day_off)
Date from year and day of year.
static struct leap_off leap_from_date(struct leap_date date)
Day from leap date.
struct leap_off leap_off(int year, int day_off)
Offsets year and day of year.
static bool equal_leap_date(struct leap_date lhs, struct leap_date rhs)
Compares two leap_date structures for equality.
Leap year date structure.
int month
Month of year starting from 1 for January.
int day
Day of month starting from 1 for the first day of the month.
Leap offset by year and day.
int day
Day of year offset.