aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/common/channel_arguments_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'test/cpp/common/channel_arguments_test.cc')
-rw-r--r--test/cpp/common/channel_arguments_test.cc23
1 files changed, 16 insertions, 7 deletions
diff --git a/test/cpp/common/channel_arguments_test.cc b/test/cpp/common/channel_arguments_test.cc
index 190d32ce06..8e7b56cbd6 100644
--- a/test/cpp/common/channel_arguments_test.cc
+++ b/test/cpp/common/channel_arguments_test.cc
@@ -230,13 +230,6 @@ TEST_F(ChannelArgumentsTest, SetSocketMutator) {
EXPECT_TRUE(HasArg(arg1));
// arg0 is replaced by arg1
EXPECT_FALSE(HasArg(arg0));
-
- // arg0 is destroyed by grpc_socket_mutator_to_arg(mutator1)
- {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- arg1.value.pointer.vtable->destroy(&exec_ctx, arg1.value.pointer.p);
- grpc_exec_ctx_finish(&exec_ctx);
- }
}
TEST_F(ChannelArgumentsTest, SetUserAgentPrefix) {
@@ -250,6 +243,22 @@ TEST_F(ChannelArgumentsTest, SetUserAgentPrefix) {
channel_args_.SetUserAgentPrefix(prefix);
EXPECT_TRUE(HasArg(arg0));
+
+ // Test if the user agent string is copied correctly
+ ChannelArguments new_channel_args(channel_args_);
+ grpc_channel_args args;
+ SetChannelArgs(new_channel_args, &args);
+ bool found = false;
+ for (size_t i = 0; i < args.num_args; i++) {
+ const grpc_arg& arg = args.args[i];
+ if (arg.type == GRPC_ARG_STRING &&
+ grpc::string(arg.key) == GRPC_ARG_PRIMARY_USER_AGENT_STRING) {
+ EXPECT_FALSE(found);
+ EXPECT_EQ(0, strcmp(arg.value.string, arg0.value.string));
+ found = true;
+ }
+ }
+ EXPECT_TRUE(found);
}
} // namespace testing