test: online/login describes returned error code
[libisds.git] / test / isds-filemetatype.c
blob686a7a97dd4394a986ea377842d6decd200a93c3
1 #include "test.h"
2 #include "isds.c"
4 static int test_filemetatype2string_must_fail(const isds_FileMetaType type) {
5 xmlChar *string;
7 string = (xmlChar *) isds_FileMetaType2string(type);
8 if (string)
9 FAIL_TEST("conversion from isds_FileMetaType to string did not fail");
11 PASS_TEST;
14 static int test_string2filemetatype_must_fail(const xmlChar *string) {
15 isds_error err;
16 isds_FileMetaType new_type;
18 err = string2isds_FileMetaType((xmlChar *)string, &new_type);
19 if (!err)
20 FAIL_TEST("conversion from string to isds_FileMetaType did not fail");
22 PASS_TEST;
25 static int test_filemetatype(const isds_FileMetaType type) {
26 xmlChar *string;
27 isds_error err;
28 isds_FileMetaType new_type;
30 string = (xmlChar *) isds_FileMetaType2string(type);
31 if (!string)
32 FAIL_TEST("conversion from isds_FileMetaType to string failed");
34 err = string2isds_FileMetaType(string, &new_type);
35 if (err)
36 FAIL_TEST("conversion from string to isds_FileMetaTyoe failed");
38 if (type != new_type)
39 FAIL_TEST("double conversion not idempotent");
41 PASS_TEST;
44 int main(int argc, char **argv) {
45 INIT_TEST("isds_FileMetaType conversion");
47 isds_FileMetaType types[] = {
48 FILEMETATYPE_MAIN, /* Main document */
49 FILEMETATYPE_ENCLOSURE, /* Appendix */
50 FILEMETATYPE_SIGNATURE, /* Digital signature of other document */
51 FILEMETATYPE_META /* XML document for ESS (electronic */
54 for (int i = 0; i < sizeof(types)/sizeof(types[0]); i++)
55 TEST(isds_FileMetaType2string(types[i]), test_filemetatype, types[i]);
57 TEST("1234", test_filemetatype2string_must_fail, 1234);
59 TEST("X-Invalid_Type", test_string2filemetatype_must_fail,
60 BAD_CAST "X-Invalid_Type");
62 SUM_TEST();