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 <memory>
15
16 #include "absl/types/optional.h"
17 #include "gtest/gtest.h"
18
19 #include <grpc/support/port_platform.h>
20
21 #include "src/core/lib/channel/channel_args.h"
22 #include "src/core/lib/event_engine/channel_args_endpoint_config.h"
23
24 using ::grpc_event_engine::experimental::ChannelArgsEndpointConfig;
25
TEST(EndpointConfigTest,CanSRetrieveValuesFromChannelArgs)26 TEST(EndpointConfigTest, CanSRetrieveValuesFromChannelArgs) {
27 grpc_core::ChannelArgs args;
28 args = args.Set("arst", 3);
29 ChannelArgsEndpointConfig config(args);
30 EXPECT_EQ(*config.GetInt("arst"), 3);
31 }
32
TEST(EndpointConfigTest,ReturnsNoValueForMissingKeys)33 TEST(EndpointConfigTest, ReturnsNoValueForMissingKeys) {
34 ChannelArgsEndpointConfig config;
35 EXPECT_TRUE(!config.GetInt("nonexistent").has_value());
36 EXPECT_TRUE(!config.GetString("nonexistent").has_value());
37 EXPECT_EQ(config.GetVoidPointer("nonexistent"), nullptr);
38 }
39
main(int argc,char ** argv)40 int main(int argc, char** argv) {
41 testing::InitGoogleTest(&argc, argv);
42 auto result = RUN_ALL_TESTS();
43 return result;
44 }
45