4 static void test_destructor(void *argument
) {
5 if (NULL
!= argument
) zfree(*(void **)argument
);
8 static int test_timeval2timestring(const struct timeval
* time
,
9 const isds_error error
, const xmlChar
*correct_string
,
10 xmlChar
**new_string
) {
13 err
= timeval2timestring(time
, new_string
);
14 TEST_DESTRUCTOR(test_destructor
, new_string
);
17 FAIL_TEST("timeval2timetring() returned unexpected code: "
18 "expected=%s got=%s", isds_strerror(error
), isds_strerror(err
));
23 if (NULL
== new_string
)
26 if (NULL
== correct_string
&& NULL
== *new_string
)
29 if (NULL
== correct_string
|| NULL
== *new_string
||
30 xmlStrcmp(correct_string
, *new_string
))
31 FAIL_TEST("Wrong time string returned: expected=`%s', got=`%s'",
32 correct_string
, *new_string
);
38 INIT_TEST("Struct timeval to ISO time string conversion");
40 xmlChar
*output
= NULL
;
41 xmlChar
*time
= BAD_CAST
"2001-02-03T04:05:06.123456";
42 struct timeval input
= {.tv_sec
= 981173106, .tv_usec
= 123456 };
43 TEST("tv_sec=981173106 tv_usec=123456", test_timeval2timestring
, &input
,
44 IE_SUCCESS
, time
, &output
);
45 input
.tv_sec
= 981173106; input
.tv_usec
= 12;
46 TEST("tv_sec=981173106 tv_usec=12", test_timeval2timestring
, &input
,
47 IE_SUCCESS
, BAD_CAST
"2001-02-03T04:05:06.000012", &output
);
49 TEST("NULL input", test_timeval2timestring
, NULL
,
50 IE_INVAL
, time
, &output
);
51 TEST("NULL output pointer", test_timeval2timestring
, &input
,
52 IE_INVAL
, time
, NULL
);