2 * Copyright 2017 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 /* Tests for the ASN1_STRING_TABLE_* functions */
15 #include <openssl/asn1.h>
18 static int test_string_tbl(void)
20 const ASN1_STRING_TABLE *tmp = NULL;
21 int nid = 12345678, nid2 = 87654321, rv = 0, ret = 0;
23 tmp = ASN1_STRING_TABLE_get(nid);
24 if (!TEST_ptr_null(tmp)) {
25 TEST_info("asn1 string table: ASN1_STRING_TABLE_get non-exist nid");
29 ret = ASN1_STRING_TABLE_add(nid, -1, -1, MBSTRING_ASC, 0);
30 if (!TEST_true(ret)) {
31 TEST_info("asn1 string table: add NID(%d) failed", nid);
35 ret = ASN1_STRING_TABLE_add(nid2, -1, -1, MBSTRING_ASC, 0);
36 if (!TEST_true(ret)) {
37 TEST_info("asn1 string table: add NID(%d) failed", nid2);
41 tmp = ASN1_STRING_TABLE_get(nid);
43 TEST_info("asn1 string table: get NID(%d) failed", nid);
47 tmp = ASN1_STRING_TABLE_get(nid2);
49 TEST_info("asn1 string table: get NID(%d) failed", nid2);
53 ASN1_STRING_TABLE_cleanup();
55 /* check if all newly added NIDs are cleaned up */
56 tmp = ASN1_STRING_TABLE_get(nid);
57 if (!TEST_ptr_null(tmp)) {
58 TEST_info("asn1 string table: get NID(%d) failed", nid);
62 tmp = ASN1_STRING_TABLE_get(nid2);
63 if (!TEST_ptr_null(tmp)) {
64 TEST_info("asn1 string table: get NID(%d) failed", nid2);
75 ADD_TEST(test_string_tbl);