1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
#include <stdlib.h>
#include <time.h>
#include <CUnit/CUnit.h>
#include "util.h"
#include "test_util.h"
void test_parse_timespec(void)
{
struct timespec *t = parse_seconds("123");
CU_ASSERT_PTR_NOT_NULL(t);
CU_ASSERT(t->tv_sec == 123);
CU_ASSERT(t->tv_nsec == 0);
free(t);
#if 0
/* Fractions are not supported, yet. */
t = parse_seconds("123.4");
CU_ASSERT_PTR_NOT_NULL(t);
CU_ASSERT(t->tv_sec == 123);
CU_ASSERT(t->tv_nsec == 400000);
free(t);
#else
CU_ASSERT_PTR_NULL(parse_seconds("123.4"));
#endif
CU_ASSERT_PTR_NULL(parse_seconds("-1"));
CU_ASSERT_PTR_NULL(parse_seconds("hello"));
}
CU_TestInfo util_tests[] = {
{ "test_parse_timespec", test_parse_timespec },
CU_TEST_INFO_NULL,
};
|