aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/common
diff options
context:
space:
mode:
authorGravatar Yuchen Zeng <zyc@google.com>2017-03-22 18:03:06 -0700
committerGravatar Yuchen Zeng <zyc@google.com>2017-03-22 18:03:06 -0700
commit9f0a115f059c3a6be619c41173a50f56364e119c (patch)
tree4e9ad1976ab62c393802db1c2aea7391d3d644f5 /test/cpp/common
parentf5b6b5b70234e406e2a6b2ddf031165b47dd5663 (diff)
Test if the user agent string is copied correctly
Diffstat (limited to 'test/cpp/common')
-rw-r--r--test/cpp/common/channel_arguments_test.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/cpp/common/channel_arguments_test.cc b/test/cpp/common/channel_arguments_test.cc
index 9bcc9f99f6..8e7b56cbd6 100644
--- a/test/cpp/common/channel_arguments_test.cc
+++ b/test/cpp/common/channel_arguments_test.cc
@@ -243,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