ocarina/tests/core/date.c

31 lines
536 B
C

/*
* Copyright 2015 (c) Anna Schumaker.
*/
#define _GNU_SOURCE
#include <core/date.h>
#include <tests/test.h>
#include <time.h>
void test_date()
{
time_t rawtime = time(NULL);
struct tm *today = localtime(&rawtime);
struct date date = {
.d_year = 0,
.d_month = 0,
.d_day = 0,
};
date_today(NULL);
date_today(&date);
test_equal(date.d_year, today->tm_year + 1900);
test_equal(date.d_month, today->tm_mon + 1);
test_equal(date.d_day, today->tm_mday);
}
DECLARE_UNIT_TESTS(
UNIT_TEST("Date", test_date),
);