]> git.ipfire.org Git - thirdparty/openssl.git/blame - test/namemap_internal_test.c
Implement EVP_MAC_do_all_ex()
[thirdparty/openssl.git] / test / namemap_internal_test.c
CommitLineData
734a462e
RL
1/*
2 * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
3 *
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
8 */
9
10#include "internal/namemap.h"
11#include "testutil.h"
12
13#define NAME1 "name1"
14#define NAME2 "name2"
15#define ALIAS1 "alias1"
a9550b74 16#define ALIAS1_UC "ALIAS1"
734a462e
RL
17
18static int test_namemap(OSSL_NAMEMAP *nm)
19{
20 int num1 = ossl_namemap_add(nm, 0, NAME1);
21 int num2 = ossl_namemap_add(nm, 0, NAME2);
22 int num3 = ossl_namemap_add(nm, num1, ALIAS1);
a9550b74 23 int num4 = ossl_namemap_add(nm, 0, ALIAS1_UC);
734a462e
RL
24 int check1 = ossl_namemap_name2num(nm, NAME1);
25 int check2 = ossl_namemap_name2num(nm, NAME2);
26 int check3 = ossl_namemap_name2num(nm, ALIAS1);
a9550b74 27 int check4 = ossl_namemap_name2num(nm, ALIAS1_UC);
734a462e
RL
28 int false1 = ossl_namemap_name2num(nm, "foo");
29
30 return TEST_int_ne(num1, 0)
31 && TEST_int_ne(num2, 0)
32 && TEST_int_eq(num1, num3)
a9550b74 33 && TEST_int_eq(num3, num4)
734a462e
RL
34 && TEST_int_eq(num1, check1)
35 && TEST_int_eq(num2, check2)
36 && TEST_int_eq(num3, check3)
a9550b74 37 && TEST_int_eq(num4, check4)
734a462e
RL
38 && TEST_int_eq(false1, 0);
39}
40
41static int test_namemap_independent(void)
42{
43 OSSL_NAMEMAP *nm = ossl_namemap_new();
44 int ok = nm != NULL && test_namemap(nm);
45
46 ossl_namemap_free(nm);
47 return ok;
48}
49
50static int test_namemap_stored(void)
51{
52 OSSL_NAMEMAP *nm = ossl_namemap_stored(NULL);
53
54 return nm != NULL
55 && test_namemap(nm);
56}
57
58int setup_tests(void)
59{
60 ADD_TEST(test_namemap_independent);
61 ADD_TEST(test_namemap_stored);
62 return 1;
63}