Debian Codegraph @

test/core/event_engine/endpoint_config_test.cc

raw
1 // Copyright 2021 The gRPC Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 #include <grpc/support/port_platform.h>
15
16 #include "absl/types/optional.h"
17 #include "gtest/gtest.h"
18
19 #include "src/core/lib/channel/channel_args.h"
20 #include "src/core/lib/event_engine/channel_args_endpoint_config.h"
21
22 using ::grpc_event_engine::experimental::ChannelArgsEndpointConfig;
23
24 TEST(EndpointConfigTest, CanSRetrieveValuesFromChannelArgs) {
25 grpc_core::ChannelArgs args;
26 args = args.Set("arst", 3);
27 ChannelArgsEndpointConfig config(args);
28 EXPECT_EQ(*config.GetInt("arst"), 3);
29 }
30
31 TEST(EndpointConfigTest, ReturnsNoValueForMissingKeys) {
32 ChannelArgsEndpointConfig config;
33 EXPECT_TRUE(!config.GetInt("nonexistent").has_value());
34 EXPECT_TRUE(!config.GetString("nonexistent").has_value());
35 EXPECT_EQ(config.GetVoidPointer("nonexistent"), nullptr);
36 }
37
38 int main(int argc, char** argv) {
39 testing::InitGoogleTest(&argc, argv);
40 auto result = RUN_ALL_TESTS();
41 return result;
42 }