diff --git a/test/cpp/interop/client.cc b/test/cpp/interop/client.cc index 2aefb620a40..173e8da0096 100644 --- a/test/cpp/interop/client.cc +++ b/test/cpp/interop/client.cc @@ -70,6 +70,7 @@ DEFINE_string( "server_streaming : single request with response streaming;\n" "slow_consumer : single request with response streaming with " "slow client consumer;\n" + "special_status_message: verify Unicode and whitespace in status message;\n" "status_code_and_message: verify status code & message;\n" "timeout_on_sleeping_server: deadline exceeds on stream;\n" "unimplemented_method: client calls an unimplemented method;\n" @@ -258,6 +259,8 @@ int main(int argc, char** argv) { } actions["status_code_and_message"] = std::bind(&grpc::testing::InteropClient::DoStatusWithMessage, &client); + actions["special_status_message"] = + std::bind(&grpc::testing::InteropClient::DoSpecialStatusMessage, &client); actions["custom_metadata"] = std::bind(&grpc::testing::InteropClient::DoCustomMetadata, &client); actions["unimplemented_method"] = diff --git a/test/cpp/interop/interop_client.cc b/test/cpp/interop/interop_client.cc index 25f1695795f..cdc621cbc9b 100644 --- a/test/cpp/interop/interop_client.cc +++ b/test/cpp/interop/interop_client.cc @@ -885,6 +885,30 @@ bool InteropClient::DoStatusWithMessage() { return true; } +bool InteropClient::DoSpecialStatusMessage() { + gpr_log( + GPR_DEBUG, + "Sending RPC with a request for status code 2 and message - \\t\\ntest " + "with whitespace\\r\\nand Unicode BMP ☺ and non-BMP 😈\\t\\n"); + const grpc::StatusCode test_code = grpc::StatusCode::UNKNOWN; + const std::string test_msg = + "\t\ntest with whitespace\r\nand Unicode BMP ☺ and non-BMP 😈\t\n"; + ClientContext context; + SimpleRequest request; + SimpleResponse response; + EchoStatus* requested_status = request.mutable_response_status(); + requested_status->set_code(test_code); + requested_status->set_message(test_msg); + Status s = serviceStub_.Get()->UnaryCall(&context, request, &response); + if (!AssertStatusCode(s, grpc::StatusCode::UNKNOWN, + context.debug_error_string())) { + return false; + } + GPR_ASSERT(s.error_message() == test_msg); + gpr_log(GPR_DEBUG, "Done testing Special Status Message"); + return true; +} + bool InteropClient::DoCacheableUnary() { gpr_log(GPR_DEBUG, "Sending RPC with cacheable response"); diff --git a/test/cpp/interop/interop_client.h b/test/cpp/interop/interop_client.h index e7a612a05b4..de564ca61bc 100644 --- a/test/cpp/interop/interop_client.h +++ b/test/cpp/interop/interop_client.h @@ -65,6 +65,8 @@ class InteropClient { bool DoTimeoutOnSleepingServer(); bool DoEmptyStream(); bool DoStatusWithMessage(); + // Verifies Unicode and Whitespace is correctly processed in status message. + bool DoSpecialStatusMessage(); bool DoCustomMetadata(); bool DoUnimplementedMethod(); bool DoUnimplementedService();