Add support for serializing tdbPersonalOwnerInfo
[libisds.git] / test / offline / isds-datestring2tm.c
blob014b4dff97b591e78e93e71eac59799c4385591e
1 #include "../test.h"
2 #include "isds.c"
4 static int test_datestring2tm(const xmlChar *date, const isds_error error,
5 const struct tm *correct_tm, struct tm *new_tm) {
6 isds_error err;
8 err = _isds_datestring2tm(date, new_tm);
9 if (err != error)
10 FAIL_TEST("_isds_datestring2tm() returned unexpected code: "
11 "expected=%s got=%s", isds_strerror(error), isds_strerror(err));
13 if (err)
14 PASS_TEST;
16 if (correct_tm->tm_year != new_tm->tm_year)
17 FAIL_TEST("Returned struct tm differs in tm_year: expected=%d, got=%d",
18 correct_tm->tm_year, new_tm->tm_year);
19 if (correct_tm->tm_mon != new_tm->tm_mon)
20 FAIL_TEST("Returned struct tm differs in tm_mon: expected=%d, got=%d",
21 correct_tm->tm_mon, new_tm->tm_mon);
22 if (correct_tm->tm_mday != new_tm->tm_mday)
23 FAIL_TEST("Returned struct tm differs in tm_mday: expected=%d, got=%d",
24 correct_tm->tm_mday, new_tm->tm_mday);
26 PASS_TEST;
29 int main(void) {
30 INIT_TEST("ISO date string to tm conversion");
32 struct tm output;
33 char *input = "2001-02-03";
34 struct tm date = {.tm_year = 101, .tm_mon = 1, .tm_mday = 3};
35 TEST(input, test_datestring2tm, BAD_CAST input, IE_SUCCESS, &date, &output);
37 input = "20010203";
38 TEST(input, test_datestring2tm, BAD_CAST input, IE_SUCCESS, &date, &output);
40 input = "2001-34";
41 TEST(input, test_datestring2tm, BAD_CAST input, IE_SUCCESS, &date, &output);
44 input = "2001-02-03T05:06";
45 TEST(input, test_datestring2tm, BAD_CAST input, IE_NOTSUP, &date, &output);
47 input = "foo bar";
48 TEST(input, test_datestring2tm, BAD_CAST input, IE_NOTSUP, &date, &output);
50 TEST("Empty input", test_datestring2tm, BAD_CAST "", IE_NOTSUP, &date,
51 &output);
53 input = NULL;
54 TEST(input, test_datestring2tm, BAD_CAST input, IE_INVAL, &date, &output);
56 TEST("NULL output pointer", test_datestring2tm, BAD_CAST "", IE_INVAL,
57 NULL, NULL);
59 SUM_TEST();