endpoint_config_test.cc 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. #include <gmock/gmock.h>
  16. #include <gtest/gtest.h>
  17. #include <grpc/event_engine/endpoint_config.h>
  18. #include <grpc/grpc.h>
  19. #include "src/core/lib/channel/channel_args.h"
  20. #include "src/core/lib/event_engine/channel_args_endpoint_config.h"
  21. #include "test/core/util/test_config.h"
  22. using ::grpc_event_engine::experimental::ChannelArgsEndpointConfig;
  23. TEST(EndpointConfigTest, CanSRetrieveValuesFromChannelArgs) {
  24. grpc_arg arg = grpc_channel_arg_integer_create(const_cast<char*>("arst"), 3);
  25. const grpc_channel_args args = {1, &arg};
  26. ChannelArgsEndpointConfig config(&args);
  27. EXPECT_EQ(absl::get<int>(config.Get("arst")), 3);
  28. }
  29. TEST(EndpointConfigTest, ReturnsMonostateForMissingKeys) {
  30. ChannelArgsEndpointConfig config(nullptr);
  31. EXPECT_TRUE(
  32. absl::holds_alternative<absl::monostate>(config.Get("nonexistent")));
  33. }
  34. int main(int argc, char** argv) {
  35. testing::InitGoogleTest(&argc, argv);
  36. auto result = RUN_ALL_TESTS();
  37. return result;
  38. }