]>
git.ipfire.org Git - thirdparty/openssl.git/blob - test/namemap_internal_test.c
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"
16 #define ALIAS1_UC "ALIAS1"
18 static int test_namemap(OSSL_NAMEMAP
*nm
)
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
);
23 int num4
= ossl_namemap_add(nm
, 0, ALIAS1_UC
);
24 int check1
= ossl_namemap_name2num(nm
, NAME1
);
25 int check2
= ossl_namemap_name2num(nm
, NAME2
);
26 int check3
= ossl_namemap_name2num(nm
, ALIAS1
);
27 int check4
= ossl_namemap_name2num(nm
, ALIAS1_UC
);
28 int false1
= ossl_namemap_name2num(nm
, "foo");
30 return TEST_int_ne(num1
, 0)
31 && TEST_int_ne(num2
, 0)
32 && TEST_int_eq(num1
, num3
)
33 && TEST_int_eq(num3
, num4
)
34 && TEST_int_eq(num1
, check1
)
35 && TEST_int_eq(num2
, check2
)
36 && TEST_int_eq(num3
, check3
)
37 && TEST_int_eq(num4
, check4
)
38 && TEST_int_eq(false1
, 0);
41 static int test_namemap_independent(void)
43 OSSL_NAMEMAP
*nm
= ossl_namemap_new();
44 int ok
= nm
!= NULL
&& test_namemap(nm
);
46 ossl_namemap_free(nm
);
50 static int test_namemap_stored(void)
52 OSSL_NAMEMAP
*nm
= ossl_namemap_stored(NULL
);
60 ADD_TEST(test_namemap_independent
);
61 ADD_TEST(test_namemap_stored
);