Update comment at isds_get_box_list_archive()
[libisds.git] / test / offline / isds-tm2datestring.c
blob155df38fe1c18fddf22a3c4c3a9aea647622cdb7
1 #include "../test.h"
2 #include "isds.c"
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) {
10 isds_error err;
12 err = tm2datestring(date, new_string);
13 TEST_DESTRUCTOR(test_destructor, new_string);
15 if (err != error)
16 FAIL_TEST("tm2datestring() returned unexpected code: "
17 "expected=%s got=%s", isds_strerror(error), isds_strerror(err));
19 if (err)
20 PASS_TEST;
22 if (NULL == new_string)
23 PASS_TEST;
25 if (NULL == *new_string && NULL != correct_string)
26 PASS_TEST;
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);
33 PASS_TEST;
36 int main(void) {
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);
50 SUM_TEST();