test: Fix indentation
[libisds.git] / test / offline / isds-filemetatype.c
blobe70ce3390bddfb3433e3f902dc6a8baf853605c5
1 #include "../test.h"
2 #include "isds.c"
4 #if HAVE_LIBCURL
5 static int test_filemetatype2string_must_fail(const isds_FileMetaType type) {
6 xmlChar *string;
8 string = (xmlChar *) isds_FileMetaType2string(type);
9 if (string)
10 FAIL_TEST("conversion from isds_FileMetaType to string did not fail");
12 PASS_TEST;
14 #endif
16 static int test_string2filemetatype_must_fail(const xmlChar *string) {
17 isds_error err;
18 isds_FileMetaType new_type;
20 err = string2isds_FileMetaType((xmlChar *)string, &new_type);
21 if (!err)
22 FAIL_TEST("conversion from string to isds_FileMetaType did not fail");
24 PASS_TEST;
27 static int test_filemetatype(const isds_FileMetaType type,
28 const xmlChar *string) {
29 isds_error err;
30 isds_FileMetaType new_type;
31 #if HAVE_LIBCURL
32 xmlChar *new_string;
34 new_string = (xmlChar *) isds_FileMetaType2string(type);
35 if (!new_string)
36 FAIL_TEST("conversion from isds_FileMetaType to string failed");
37 if (xmlStrcmp(string, new_string))
38 FAIL_TEST("conversion from isds_FileMetaType %zd to string returned "
39 "unexpected value: got=`%s', expected=`%s'",
40 type, new_string, string);
41 #endif /* HAVE_LIBCURL */
43 err = string2isds_FileMetaType(string, &new_type);
44 if (err)
45 FAIL_TEST("conversion from string to isds_FileMetaTyoe failed");
46 if (type != new_type)
47 FAIL_TEST("conversion from string `%s' to isds_FileMetaType returned "
48 "unexpected valued: got=%zd, expected=%zd",
49 string, new_type, type);
51 PASS_TEST;
54 int main(void) {
55 INIT_TEST("isds_FileMetaType conversion");
57 isds_FileMetaType types[] = {
58 FILEMETATYPE_MAIN, /* Main document */
59 FILEMETATYPE_ENCLOSURE, /* Appendix */
60 FILEMETATYPE_SIGNATURE, /* Digital signature of other document */
61 FILEMETATYPE_META /* XML document for ESS (electronic */
63 const xmlChar *strings[] = {
64 BAD_CAST "main",
65 BAD_CAST "enclosure",
66 BAD_CAST "signature",
67 BAD_CAST "meta"
70 for (size_t i = 0; i < sizeof(types)/sizeof(types[0]); i++)
71 TEST(strings[i], test_filemetatype, types[i], strings[i]);
73 #if HAVE_LIBCURL
74 TEST("1234", test_filemetatype2string_must_fail, 1234);
75 #endif
77 TEST("X-Invalid_Type", test_string2filemetatype_must_fail,
78 BAD_CAST "X-Invalid_Type");
80 SUM_TEST();