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