test: Silent a compiler warning in isds-hash_algorithm.c
[libisds.git] / test / offline / isds-hash_algorithm.c
blobfa8b1777f0b0bdf3682829a253820369be25de6c
1 #include "../test.h"
2 #include "isds.c"
4 static int test_string2hashalgorithm(const xmlChar *name,
5 const isds_error error, const isds_hash_algorithm type) {
6 isds_error err;
7 isds_hash_algorithm new_type = -1; /* ??? GCC-4.7.3 at -O3 complains on
8 possibly undefined new_type in the
9 `type != new_type' code. */
11 err = string2isds_hash_algorithm(name, &new_type);
12 if (err != error)
13 FAIL_TEST("string2isds_hash_algorithm() returned unexpected code");
15 if (err)
16 PASS_TEST;
18 if (type != new_type)
19 FAIL_TEST("conversion returned wrong algorithm");
21 PASS_TEST;
24 int main(int argc, char **argv) {
25 INIT_TEST("isds_hash_algorithm conversion");
27 xmlChar *names[] = {
28 BAD_CAST "MD5",
29 BAD_CAST "SHA-1",
30 BAD_CAST "SHA-224",
31 BAD_CAST "SHA-256",
32 BAD_CAST "SHA-384",
33 BAD_CAST "SHA-512"
36 isds_hash_algorithm algos[] = {
37 HASH_ALGORITHM_MD5,
38 HASH_ALGORITHM_SHA_1,
39 HASH_ALGORITHM_SHA_224,
40 HASH_ALGORITHM_SHA_256,
41 HASH_ALGORITHM_SHA_384,
42 HASH_ALGORITHM_SHA_512,
45 for (int i = 0; i < sizeof(algos)/sizeof(algos[0]); i++)
46 TEST(names[i], test_string2hashalgorithm, names[i], IE_SUCCESS,
47 algos[i]);
49 TEST("X-Invalid_Type", test_string2hashalgorithm, BAD_CAST "X-Invalid_Type",
50 IE_ENUM, 0);
52 SUM_TEST();