4 static int test_tm2datestring(const struct tm
* date
, const isds_error error
,
5 const xmlChar
*correct_string
, xmlChar
**new_string
) {
8 err
= tm2datestring(date
, new_string
);
10 if (new_string
) zfree(*new_string
);
11 FAIL_TEST("tm2datestring() returned unexpected code: "
12 "expected=%s got=%s", isds_strerror(error
), isds_strerror(err
));
16 if (new_string
) zfree(*new_string
);
20 if (!*new_string
&& !correct_string
)
23 if (!correct_string
|| !*new_string
||
24 xmlStrcmp(correct_string
, *new_string
)) {
25 if (new_string
) zfree(*new_string
);
26 FAILURE_REASON("Wrong date string returned: expected=`%s', got=`%s'",
27 correct_string
, *new_string
);
31 if (new_string
) zfree(*new_string
);
35 int main(int argc
, char **argv
) {
36 INIT_TEST("Struct tm to ISO date string conversion");
38 xmlChar
*output
= NULL
;
39 xmlChar
*date
= BAD_CAST
"2001-02-03";
40 struct tm input
= {.tm_year
= 101, .tm_mon
= 1, .tm_mday
= 3};
41 TEST("tm_year=101 tm_mon=1 tm_mday=3", test_tm2datestring
, &input
,
42 IE_SUCCESS
, date
, &output
);
44 TEST("NULL input", test_tm2datestring
, NULL
,
45 IE_INVAL
, date
, &output
);
46 TEST("NULL output pointer", test_tm2datestring
, &input
,
47 IE_INVAL
, date
, NULL
);