4 static int test_usertype2string_must_fail(const isds_UserType type
) {
7 string
= (xmlChar
*) isds_UserType2string(type
);
9 FAIL_TEST("conversion from isds_UserType to string did not fail");
14 static int test_string2usertype_must_fail(const xmlChar
*string
) {
16 isds_UserType new_type
;
18 err
= string2isds_UserType((xmlChar
*)string
, &new_type
);
20 FAIL_TEST("conversion from string to isds_UserType did not fail");
25 static int test_usertype(const isds_UserType type
, const xmlChar
*name
) {
28 isds_UserType new_type
;
30 string
= (xmlChar
*) isds_UserType2string(type
);
32 FAIL_TEST("conversion from isds_UserType to string failed");
34 if (xmlStrcmp(name
, string
))
35 FAIL_TEST("Wrong to string conversion result: "
36 "expected=`%s', got=`%s'", name
, string
);
38 err
= string2isds_UserType(string
, &new_type
);
40 FAIL_TEST("conversion from string to isds_DbTyoe failed");
43 FAIL_TEST("double conversion not idempotent: expected=%d, got=%d",
50 INIT_TEST("isds_UserType conversion");
52 isds_UserType types
[] = {
55 USERTYPE_ADMINISTRATOR
,
57 USERTYPE_OFFICIAL_CERT
,
61 const xmlChar
*names
[] = {
62 BAD_CAST
"PRIMARY_USER",
63 BAD_CAST
"ENTRUSTED_USER",
64 BAD_CAST
"ADMINISTRATOR",
66 BAD_CAST
"OFFICIAL_CERT",
71 for (size_t i
= 0; i
< sizeof(types
)/sizeof(types
[0]); i
++)
72 TEST(isds_UserType2string(types
[i
]), test_usertype
, types
[i
], names
[i
]);
74 TEST("1234", test_usertype2string_must_fail
, 1234);
76 TEST("X-Invalid_Type", test_string2usertype_must_fail
,
77 BAD_CAST
"X-Invalid_Type");