X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=tests%2Funit%2Fdatetime.c;fp=tests%2Funit%2Fdatetime.c;h=591dc9f2349d993d8102d76df9f7160c0ca22acf;hb=e7cd0a76bde8f0a8d6d88e172546be10500cc645;hp=0000000000000000000000000000000000000000;hpb=94deca2a10922ae4bc192b63dbbebf940d0e7d24;p=projects%2Fchimara%2Fchimara.git diff --git a/tests/unit/datetime.c b/tests/unit/datetime.c new file mode 100644 index 0000000..591dc9f --- /dev/null +++ b/tests/unit/datetime.c @@ -0,0 +1,26 @@ +#include "glk.h" +#include "glkunit.h" + +static int +test_current_time_equals_current_simple_time(void) +{ + glktimeval_t timeval; + + /* This test will fail if the following two operations do not occur within + a second of each other. That is not a robust test, but you could argue that + there is a serious bug if either operation takes more than one second. */ + glk_current_time(&timeval); + glsi32 simple_time = glk_current_simple_time(1); + ASSERT_EQUAL(simple_time, timeval.low_sec); + + glk_current_time(&timeval); + glsi32 simple_time_high_bits = glk_current_simple_time(0xFFFFFFFF); + ASSERT_EQUAL(simple_time_high_bits, timeval.high_sec); + + SUCCEED; +} + +struct TestDescription tests[] = { + { "current time equals simple time", test_current_time_equals_current_simple_time }, + { NULL, NULL } +};