4 static int test_string2sendertype(const xmlChar
*string
, isds_error error
,
5 isds_sender_type
*type
) {
7 isds_sender_type new_type
= 0;
9 err
= string2isds_sender_type(string
, (type
) ? &new_type
: NULL
);
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
)
17 if (type
&& *type
!= new_type
)
18 FAIL_TEST("string2isds_sender_type() returned wrong type: "
19 "expected=%d, got=%d", *type
, new_type
);
25 INIT_TEST("isds_sender_type conversion");
27 isds_sender_type types
[] = {
30 SENDERTYPE_ADMINISTRATOR
,
33 SENDERTYPE_OFFICIAL_CERT
,
37 const xmlChar
*names
[] = {
38 BAD_CAST
"PRIMARY_USER",
39 BAD_CAST
"ENTRUSTED_USER",
40 BAD_CAST
"ADMINISTRATOR",
43 BAD_CAST
"OFFICIAL_CERT",
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
]);
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
);