Skip to content
This repository has been archived by the owner on Mar 28, 2022. It is now read-only.

Commit

Permalink
Use 'std::to_string()' instead of 'stringify()'
Browse files Browse the repository at this point in the history
  • Loading branch information
benh committed Feb 20, 2022
1 parent d361df6 commit 43f0f62
Show file tree
Hide file tree
Showing 11 changed files with 11 additions and 25 deletions.
2 changes: 1 addition & 1 deletion test/cancelled-by-client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ TEST_F(EventualsGrpcTest, CancelledByClient) {
Borrowable<CompletionPool> pool;

Client client(
"0.0.0.0:" + stringify(port),
"0.0.0.0:" + std::to_string(port),
grpc::InsecureChannelCredentials(),
pool.Borrow());

Expand Down
2 changes: 1 addition & 1 deletion test/cancelled-by-server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ TEST_F(EventualsGrpcTest, CancelledByServer) {
Borrowable<CompletionPool> pool;

Client client(
"0.0.0.0:" + stringify(port),
"0.0.0.0:" + std::to_string(port),
grpc::InsecureChannelCredentials(),
pool.Borrow());

Expand Down
2 changes: 1 addition & 1 deletion test/deadline.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ TEST_F(EventualsGrpcTest, Deadline) {
Borrowable<CompletionPool> pool;

Client client(
"0.0.0.0:" + stringify(port),
"0.0.0.0:" + std::to_string(port),
grpc::InsecureChannelCredentials(),
pool.Borrow());

Expand Down
2 changes: 1 addition & 1 deletion test/greeter-server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ TEST_F(EventualsGrpcTest, Greeter) {
Borrowable<CompletionPool> pool;

Client client(
"0.0.0.0:" + stringify(port),
"0.0.0.0:" + std::to_string(port),
grpc::InsecureChannelCredentials(),
pool.Borrow());

Expand Down
2 changes: 1 addition & 1 deletion test/multiple-hosts.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ TEST_F(EventualsGrpcTest, MultipleHosts) {
Borrowable<CompletionPool> pool;

Client client(
"0.0.0.0:" + stringify(port),
"0.0.0.0:" + std::to_string(port),
grpc::InsecureChannelCredentials(),
pool.Borrow());

Expand Down
2 changes: 1 addition & 1 deletion test/server-death-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ TEST_F(EventualsGrpcTest, ServerDeathTest) {
Borrowable<CompletionPool> pool;

Client client(
"0.0.0.0:" + stringify(port),
"0.0.0.0:" + std::to_string(port),
grpc::InsecureChannelCredentials(),
pool.Borrow());

Expand Down
2 changes: 1 addition & 1 deletion test/server-unavailable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
4 changes: 2 additions & 2 deletions test/streaming.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void test_client_behavior(Handler handler) {
std::vector<keyvaluestore::Response> 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));
Expand All @@ -101,7 +101,7 @@ void test_client_behavior(Handler handler) {
Borrowable<CompletionPool> pool;

Client client(
"0.0.0.0:" + stringify(port),
"0.0.0.0:" + std::to_string(port),
grpc::InsecureChannelCredentials(),
pool.Borrow());

Expand Down
14 changes: 0 additions & 14 deletions test/test.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename T>
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();
}

////////////////////////////////////////////////////////////////////////
2 changes: 1 addition & 1 deletion test/unary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ TEST_F(EventualsGrpcTest, Unary) {
Borrowable<CompletionPool> pool;

Client client(
"0.0.0.0:" + stringify(port),
"0.0.0.0:" + std::to_string(port),
grpc::InsecureChannelCredentials(),
pool.Borrow());

Expand Down
2 changes: 1 addition & 1 deletion test/unimplemented.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ TEST_F(EventualsGrpcTest, Unimplemented) {
Borrowable<CompletionPool> pool;

Client client(
"0.0.0.0:" + stringify(port),
"0.0.0.0:" + std::to_string(port),
grpc::InsecureChannelCredentials(),
pool.Borrow());

Expand Down

0 comments on commit 43f0f62

Please sign in to comment.