Update comment at isds_get_box_list_archive()
[libisds.git] / test / offline / isds-sendertype.c
blobb57150a29339971c879836aeadec26694c398ca6
1 #include "../test.h"
2 #include "isds.c"
4 static int test_string2sendertype(const xmlChar *string, isds_error error,
5 isds_sender_type *type) {
6 isds_error err;
7 isds_sender_type new_type = 0;
9 err = string2isds_sender_type(string, (type) ? &new_type : NULL);
10 if (err != error)
11 FAIL_TEST("string2isds_sender_type() returend wrong exit code: "
12 "expected=%s, got=%s",
13 isds_strerror(error), isds_strerror(err));
14 if (err != IE_SUCCESS)
15 PASS_TEST;
17 if (type && *type != new_type)
18 FAIL_TEST("string2isds_sender_type() returned wrong type: "
19 "expected=%d, got=%d", *type, new_type);
21 PASS_TEST;
24 int main(void) {
25 INIT_TEST("isds_sender_type conversion");
27 isds_sender_type types[] = {
28 SENDERTYPE_PRIMARY,
29 SENDERTYPE_ENTRUSTED,
30 SENDERTYPE_ADMINISTRATOR,
31 SENDERTYPE_OFFICIAL,
32 SENDERTYPE_VIRTUAL,
33 SENDERTYPE_OFFICIAL_CERT,
34 SENDERTYPE_LIQUIDATOR
37 const xmlChar *names[] = {
38 BAD_CAST "PRIMARY_USER",
39 BAD_CAST "ENTRUSTED_USER",
40 BAD_CAST "ADMINISTRATOR",
41 BAD_CAST "OFFICIAL",
42 BAD_CAST "VIRTUAL",
43 BAD_CAST "OFFICIAL_CERT",
44 BAD_CAST "LIQUIDATOR"
48 /* Known values */
49 for (size_t i = 0; i < sizeof(types)/sizeof(types[0]); i++)
50 TEST(names[i], test_string2sendertype,
51 names[i], IE_SUCCESS, &types[i]);
53 /* Uknown value */
54 TEST("X-Invalid_Type", test_string2sendertype,
55 BAD_CAST "X-Invalid_Type", IE_ENUM, &types[0]);
57 /* Invalid invocation */
58 TEST("NULL string", test_string2sendertype,
59 BAD_CAST NULL, IE_INVAL, &types[0]);
60 TEST("NULL type", test_string2sendertype,
61 names[0], IE_INVAL, NULL);
62 SUM_TEST();