grpc
third_party
boringssl-with-bazel
src
crypto
conf
conf_test.cc
Go to the documentation of this file.
1
/* Copyright (c) 2021, Google Inc.
2
*
3
* Permission to use, copy, modify, and/or distribute this software for any
4
* purpose with or without fee is hereby granted, provided that the above
5
* copyright notice and this permission notice appear in all copies.
6
*
7
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
10
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
12
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
13
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
14
15
#include <
openssl/bio.h
>
16
#include <
openssl/conf.h
>
17
18
#include <gtest/gtest.h>
19
20
21
TEST
(ConfTest,
Parse
) {
22
// Check that basic parsing works. (We strongly recommend that people don't
23
// use the [N]CONF functions.)
24
25
static
const
char
kConf[] = R
"(
26
# Comment
27
28
key=value
29
30
[section_name]
31
key=value2
32
)";
33
34
bssl::UniquePtr<BIO> bio(
BIO_new_mem_buf
(kConf,
sizeof
(kConf) - 1));
35
ASSERT_TRUE
(bio);
36
bssl::UniquePtr<CONF>
conf
(
NCONF_new
(
nullptr
));
37
ASSERT_TRUE
(
conf
);
38
ASSERT_TRUE
(
NCONF_load_bio
(
conf
.get(), bio.get(),
nullptr
));
39
EXPECT_TRUE
(
NCONF_get_section
(
conf
.get(),
"section_name"
));
40
EXPECT_FALSE
(
NCONF_get_section
(
conf
.get(),
"other_section"
));
41
EXPECT_STREQ
(
NCONF_get_string
(
conf
.get(),
nullptr
,
"key"
),
"value"
);
42
EXPECT_STREQ
(
NCONF_get_string
(
conf
.get(),
"section_name"
,
"key"
),
"value2"
);
43
EXPECT_STREQ
(
NCONF_get_string
(
conf
.get(),
"other_section"
,
"key"
),
nullptr
);
44
}
EXPECT_FALSE
#define EXPECT_FALSE(condition)
Definition:
bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1970
bio.h
NCONF_get_section
#define NCONF_get_section
Definition:
boringssl_prefix_symbols.h:1823
NCONF_new
#define NCONF_new
Definition:
boringssl_prefix_symbols.h:1827
BIO_new_mem_buf
#define BIO_new_mem_buf
Definition:
boringssl_prefix_symbols.h:820
absl::flags_internal::Parse
bool Parse(FlagOpFn op, absl::string_view text, void *dst, std::string *error)
Definition:
abseil-cpp/absl/flags/internal/flag.h:125
conf.h
EXPECT_STREQ
#define EXPECT_STREQ(s1, s2)
Definition:
bloaty/third_party/googletest/googletest/include/gtest/gtest.h:2095
NCONF_load_bio
#define NCONF_load_bio
Definition:
boringssl_prefix_symbols.h:1826
ASSERT_TRUE
#define ASSERT_TRUE(condition)
Definition:
bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1973
EXPECT_TRUE
#define EXPECT_TRUE(condition)
Definition:
bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1967
NCONF_get_string
#define NCONF_get_string
Definition:
boringssl_prefix_symbols.h:1824
TEST
TEST(ConfTest, Parse)
Definition:
conf_test.cc:21
conf
Definition:
doc/python/sphinx/conf.py:1
grpc
Author(s):
autogenerated on Fri May 16 2025 02:58:00