X-Git-Url: https://git.stderr.nl/gitweb?p=projects%2Fchimara%2Fchimara.git;a=blobdiff_plain;f=tests%2Funit%2Fdatetime.c;fp=tests%2Funit%2Fdatetime.c;h=591dc9f2349d993d8102d76df9f7160c0ca22acf;hp=0000000000000000000000000000000000000000;hb=ad091d02678a632f0f91f26072bbec29eba4c66e;hpb=9b7445bd66c18e85b0d312f0c12a5050fe528073 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 } +};