Update library version
[libisds.git] / test / offline / isds-hash_algorithm.c
blob39db53921f1c8d6832dc23cf649f11267751abc2
1 #include "../test.h"
2 #include "isds.c"
4 static int test_string2hashalgorithm(const xmlChar *name, const isds_error error,
5 const isds_hash_algorithm type) {
6 isds_error err;
7 isds_hash_algorithm new_type;
9 err = string2isds_hash_algorithm(name, &new_type);
10 if (err != error)
11 FAIL_TEST("string2isds_hash_algorithm() returned unexpected code");
13 if (err)
14 PASS_TEST;
16 if (type != new_type)
17 FAIL_TEST("conversion returned wrong algorithm");
19 PASS_TEST;
22 int main(int argc, char **argv) {
23 INIT_TEST("isds_hash_algorithm conversion");
25 xmlChar *names[] = {
26 BAD_CAST "MD5",
27 BAD_CAST "SHA-1",
28 BAD_CAST "SHA-224",
29 BAD_CAST "SHA-256",
30 BAD_CAST "SHA-384",
31 BAD_CAST "SHA-512"
34 isds_hash_algorithm algos[] = {
35 HASH_ALGORITHM_MD5,
36 HASH_ALGORITHM_SHA_1,
37 HASH_ALGORITHM_SHA_224,
38 HASH_ALGORITHM_SHA_256,
39 HASH_ALGORITHM_SHA_384,
40 HASH_ALGORITHM_SHA_512,
43 for (int i = 0; i < sizeof(algos)/sizeof(algos[0]); i++)
44 TEST(names[i], test_string2hashalgorithm, names[i], IE_SUCCESS,
45 algos[i]);
47 TEST("X-Invalid_Type", test_string2hashalgorithm, BAD_CAST "X-Invalid_Type",
48 IE_ENUM, 0);
50 SUM_TEST();