From 8fc2a02e176b374e0808a6dd8c1668c273b6044a Mon Sep 17 00:00:00 2001 From: Benjamin Hindman Date: Sun, 20 Feb 2022 10:45:06 -1000 Subject: [PATCH] Use 'std::to_string()' instead of 'stringify()' --- test/cancelled-by-client.cc | 2 +- test/cancelled-by-server.cc | 2 +- test/deadline.cc | 2 +- test/greeter-server.cc | 2 +- test/multiple-hosts.cc | 2 +- test/server-death-test.cc | 2 +- test/server-unavailable.cc | 2 +- test/streaming.cc | 4 ++-- test/test.h | 14 -------------- test/unary.cc | 2 +- test/unimplemented.cc | 2 +- 11 files changed, 11 insertions(+), 25 deletions(-) diff --git a/test/cancelled-by-client.cc b/test/cancelled-by-client.cc index 76c6236..c54972b 100644 --- a/test/cancelled-by-client.cc +++ b/test/cancelled-by-client.cc @@ -56,7 +56,7 @@ TEST_F(EventualsGrpcTest, CancelledByClient) { Borrowable pool; Client client( - "0.0.0.0:" + stringify(port), + "0.0.0.0:" + std::to_string(port), grpc::InsecureChannelCredentials(), pool.Borrow()); diff --git a/test/cancelled-by-server.cc b/test/cancelled-by-server.cc index dc8b78d..e8c24e3 100644 --- a/test/cancelled-by-server.cc +++ b/test/cancelled-by-server.cc @@ -57,7 +57,7 @@ TEST_F(EventualsGrpcTest, CancelledByServer) { Borrowable pool; Client client( - "0.0.0.0:" + stringify(port), + "0.0.0.0:" + std::to_string(port), grpc::InsecureChannelCredentials(), pool.Borrow()); diff --git a/test/deadline.cc b/test/deadline.cc index c4c697f..c2f71b9 100644 --- a/test/deadline.cc +++ b/test/deadline.cc @@ -59,7 +59,7 @@ TEST_F(EventualsGrpcTest, Deadline) { Borrowable pool; Client client( - "0.0.0.0:" + stringify(port), + "0.0.0.0:" + std::to_string(port), grpc::InsecureChannelCredentials(), pool.Borrow()); diff --git a/test/greeter-server.cc b/test/greeter-server.cc index 457e457..00060b7 100644 --- a/test/greeter-server.cc +++ b/test/greeter-server.cc @@ -60,7 +60,7 @@ TEST_F(EventualsGrpcTest, Greeter) { Borrowable pool; Client client( - "0.0.0.0:" + stringify(port), + "0.0.0.0:" + std::to_string(port), grpc::InsecureChannelCredentials(), pool.Borrow()); diff --git a/test/multiple-hosts.cc b/test/multiple-hosts.cc index 4298a8a..5d11ffc 100644 --- a/test/multiple-hosts.cc +++ b/test/multiple-hosts.cc @@ -69,7 +69,7 @@ TEST_F(EventualsGrpcTest, MultipleHosts) { Borrowable pool; Client client( - "0.0.0.0:" + stringify(port), + "0.0.0.0:" + std::to_string(port), grpc::InsecureChannelCredentials(), pool.Borrow()); diff --git a/test/server-death-test.cc b/test/server-death-test.cc index b24b3ba..b2547b1 100644 --- a/test/server-death-test.cc +++ b/test/server-death-test.cc @@ -84,7 +84,7 @@ TEST_F(EventualsGrpcTest, ServerDeathTest) { Borrowable pool; Client client( - "0.0.0.0:" + stringify(port), + "0.0.0.0:" + std::to_string(port), grpc::InsecureChannelCredentials(), pool.Borrow()); diff --git a/test/server-unavailable.cc b/test/server-unavailable.cc index b8f731b..8f27486 100644 --- a/test/server-unavailable.cc +++ b/test/server-unavailable.cc @@ -23,7 +23,7 @@ TEST_F(EventualsGrpcTest, ServerUnavailable) { // NOTE: we use 'getpid()' to create a _unique_ UNIX domain socket // path that should never have a server listening on for this test. Client client( - "unix:eventuals-grpc-test-server-unavailable-" + stringify(getpid()), + "unix:eventuals-grpc-test-server-unavailable-" + std::to_string(getpid()), grpc::InsecureChannelCredentials(), pool.Borrow()); diff --git a/test/streaming.cc b/test/streaming.cc index 8aebc35..004baae 100644 --- a/test/streaming.cc +++ b/test/streaming.cc @@ -85,7 +85,7 @@ void test_client_behavior(Handler handler) { std::vector responses; for (size_t i = 0; i < 3; i++) { keyvaluestore::Response response; - response.set_value(stringify(i + 10)); + response.set_value(std::to_string(i + 10)); responses.push_back(response); } return Iterate(std::move(responses)); @@ -101,7 +101,7 @@ void test_client_behavior(Handler handler) { Borrowable pool; Client client( - "0.0.0.0:" + stringify(port), + "0.0.0.0:" + std::to_string(port), grpc::InsecureChannelCredentials(), pool.Borrow()); diff --git a/test/test.h b/test/test.h index 86579c1..3c93650 100644 --- a/test/test.h +++ b/test/test.h @@ -35,17 +35,3 @@ class EventualsGrpcTest : public ::testing::Test { std::filesystem::path GetRunfilePathFor(const std::filesystem::path& runfile); //////////////////////////////////////////////////////////////////////// - -// TODO(benh): Move to stout-stringify. -template -std::string stringify(const T& t) { - std::ostringstream out; - out << t; - if (!out.good()) { - std::cerr << "Failed to stringify!" << std::endl; - abort(); - } - return out.str(); -} - -//////////////////////////////////////////////////////////////////////// diff --git a/test/unary.cc b/test/unary.cc index 4b9eb1c..991cc2f 100644 --- a/test/unary.cc +++ b/test/unary.cc @@ -69,7 +69,7 @@ TEST_F(EventualsGrpcTest, Unary) { Borrowable pool; Client client( - "0.0.0.0:" + stringify(port), + "0.0.0.0:" + std::to_string(port), grpc::InsecureChannelCredentials(), pool.Borrow()); diff --git a/test/unimplemented.cc b/test/unimplemented.cc index 29a4755..dfbb1b5 100644 --- a/test/unimplemented.cc +++ b/test/unimplemented.cc @@ -38,7 +38,7 @@ TEST_F(EventualsGrpcTest, Unimplemented) { Borrowable pool; Client client( - "0.0.0.0:" + stringify(port), + "0.0.0.0:" + std::to_string(port), grpc::InsecureChannelCredentials(), pool.Borrow());