4 static void test_destructor(void *string
) {
5 if (NULL
!= string
) zfree(*(void **)string
);
8 static int test_tm2datestring(const struct tm
* date
, const isds_error error
,
9 const xmlChar
*correct_string
, xmlChar
**new_string
) {
12 err
= tm2datestring(date
, new_string
);
13 TEST_DESTRUCTOR(test_destructor
, new_string
);
16 FAIL_TEST("tm2datestring() returned unexpected code: "
17 "expected=%s got=%s", isds_strerror(error
), isds_strerror(err
));
22 if (NULL
== new_string
)
25 if (NULL
== *new_string
&& NULL
!= correct_string
)
28 if (NULL
== correct_string
|| NULL
== *new_string
||
29 xmlStrcmp(correct_string
, *new_string
))
30 FAIL_TEST("Wrong date string returned: expected=`%s', got=`%s'",
31 correct_string
, *new_string
);
37 INIT_TEST("Struct tm to ISO date string conversion");
39 xmlChar
*output
= NULL
;
40 xmlChar
*date
= BAD_CAST
"2001-02-03";
41 struct tm input
= {.tm_year
= 101, .tm_mon
= 1, .tm_mday
= 3};
42 TEST("tm_year=101 tm_mon=1 tm_mday=3", test_tm2datestring
, &input
,
43 IE_SUCCESS
, date
, &output
);
45 TEST("NULL input", test_tm2datestring
, NULL
,
46 IE_INVAL
, date
, &output
);
47 TEST("NULL output pointer", test_tm2datestring
, &input
,
48 IE_INVAL
, date
, NULL
);