2 * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
10 #include "internal/namemap.h"
15 #define ALIAS1 "alias1"
17 static int test_namemap(OSSL_NAMEMAP *nm)
19 int num1 = ossl_namemap_add(nm, 0, NAME1);
20 int num2 = ossl_namemap_add(nm, 0, NAME2);
21 int num3 = ossl_namemap_add(nm, num1, ALIAS1);
22 int check1 = ossl_namemap_name2num(nm, NAME1);
23 int check2 = ossl_namemap_name2num(nm, NAME2);
24 int check3 = ossl_namemap_name2num(nm, ALIAS1);
25 int false1 = ossl_namemap_name2num(nm, "foo");
27 return TEST_int_ne(num1, 0)
28 && TEST_int_ne(num2, 0)
29 && TEST_int_eq(num1, num3)
30 && TEST_int_eq(num1, check1)
31 && TEST_int_eq(num2, check2)
32 && TEST_int_eq(num3, check3)
33 && TEST_int_eq(false1, 0);
36 static int test_namemap_independent(void)
38 OSSL_NAMEMAP *nm = ossl_namemap_new();
39 int ok = nm != NULL && test_namemap(nm);
41 ossl_namemap_free(nm);
45 static int test_namemap_stored(void)
47 OSSL_NAMEMAP *nm = ossl_namemap_stored(NULL);
55 ADD_TEST(test_namemap_independent);
56 ADD_TEST(test_namemap_stored);