l10n: Update translation catalogues
[libisds.git] / test / offline / isds-crediteventtype.c
blob571f5ba2bfbd2df3b5d27156b24504624de358b2
1 #include "../test.h"
2 #include "isds.c"
4 static int test_string2isds_credit_event_type(const xmlChar *string,
5 isds_error error, isds_credit_event_type *type) {
6 isds_error err;
7 isds_credit_event_type new_type;
9 err = string2isds_credit_event_type(string, (type) ? &new_type : NULL);
10 if (err != error)
11 FAIL_TEST("string2isds_credit_event_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 != new_type)
18 FAIL_TEST("string2isds_credit_event_type() returned wrong type: "
19 "expected=%d, got=%d", *type, new_type);
21 PASS_TEST;
24 int main(void) {
25 INIT_TEST("credit_event_type conversion");
27 const xmlChar *names[] = {
28 BAD_CAST "1",
29 BAD_CAST "2",
30 BAD_CAST "3",
31 BAD_CAST "4",
32 BAD_CAST "5",
35 isds_credit_event_type types[] = {
36 ISDS_CREDIT_CHARGED,
37 ISDS_CREDIT_DISCHARGED,
38 ISDS_CREDIT_MESSAGE_SENT,
39 ISDS_CREDIT_STORAGE_SET,
40 ISDS_CREDIT_EXPIRED,
44 /* Known values */
45 for (size_t i = 0; i < sizeof(types)/sizeof(types[0]); i++)
46 TEST(names[i], test_string2isds_credit_event_type,
47 names[i], IE_SUCCESS, &types[i]);
49 /* Uknown value */
50 TEST("X-Invalid_Type", test_string2isds_credit_event_type,
51 BAD_CAST "X-Invalid_Type", IE_ENUM, &types[0]);
53 /* Invalid invocation */
54 TEST("NULL string", test_string2isds_credit_event_type,
55 BAD_CAST NULL, IE_INVAL, &types[0]);
56 TEST("NULL type", test_string2isds_credit_event_type,
57 names[0], IE_INVAL, NULL);
58 SUM_TEST();