test: Fix indentation
[libisds.git] / test / offline / isds-paymenttype.c
blobdea113ce9b80e7ece31ced89e2cba4896a656f7c
1 #include "../test.h"
2 #include "isds.c"
4 static int test_string2isds_payment_type(const xmlChar *string,
5 isds_error error, isds_payment_type *type) {
6 isds_error err;
7 isds_payment_type new_type = 0;
9 err = string2isds_payment_type(string, (type) ? &new_type : NULL);
10 if (err != error)
11 FAIL_TEST("string2isds_payment_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_payment_type() returned wrong type: "
19 "expected=%d, got=%d", *type, new_type);
21 PASS_TEST;
24 int main(void) {
25 INIT_TEST("isds_payment_type conversion");
27 const xmlChar *names[] = {
28 BAD_CAST "K",
29 BAD_CAST "E",
30 BAD_CAST "G",
31 BAD_CAST "O",
32 BAD_CAST "Z",
33 BAD_CAST "D",
36 isds_payment_type types[] = {
37 PAYMENT_SENDER,
38 PAYMENT_STAMP,
39 PAYMENT_SPONSOR,
40 PAYMENT_RESPONSE,
41 PAYMENT_SPONSOR_LIMITED,
42 PAYMENT_SPONSOR_EXTERNAL
46 /* Known values */
47 for (size_t i = 0; i < sizeof(types)/sizeof(types[0]); i++)
48 TEST(names[i], test_string2isds_payment_type,
49 names[i], IE_SUCCESS, &types[i]);
51 /* Uknown value */
52 TEST("X-Invalid_Type", test_string2isds_payment_type,
53 BAD_CAST "X-Invalid_Type", IE_ENUM, &types[0]);
55 /* Invalid invocation */
56 TEST("NULL string", test_string2isds_payment_type,
57 BAD_CAST NULL, IE_INVAL, &types[0]);
58 TEST("NULL type", test_string2isds_payment_type,
59 names[0], IE_INVAL, NULL);
60 SUM_TEST();