aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorGravatar Vijay Pai <vpai@google.com>2016-06-15 13:08:00 -0700
committerGravatar Vijay Pai <vpai@google.com>2016-06-15 13:10:32 -0700
commit679c75f0a67d65f115bb44521f49da3db14c2ad2 (patch)
tree0ae450f6d22023f5be6d1b73c02092680c2af712 /test
parenta63271c77f7ee4802761535f8c844f789328ad9f (diff)
Deal with issues surrounding const members of classes used in
containers
Diffstat (limited to 'test')
-rw-r--r--test/cpp/end2end/async_end2end_test.cc11
-rw-r--r--test/cpp/end2end/end2end_test.cc9
2 files changed, 13 insertions, 7 deletions
diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc
index 2e0c9da107..029bdc8bce 100644
--- a/test/cpp/end2end/async_end2end_test.cc
+++ b/test/cpp/end2end/async_end2end_test.cc
@@ -233,8 +233,11 @@ class TestScenario {
disable_blocking, credentials_type.c_str(), message_content.size());
}
bool disable_blocking;
- const grpc::string credentials_type;
- const grpc::string message_content;
+ // Although the below grpc::string's are logically const, we can't declare
+ // them const because of a limitation in the way old compilers (e.g., gcc-4.4)
+ // manage vector insertion using a copy constructor
+ grpc::string credentials_type;
+ grpc::string message_content;
};
class AsyncEnd2endTest : public ::testing::TestWithParam<TestScenario> {
@@ -1395,9 +1398,9 @@ std::vector<TestScenario> CreateTestScenarios(bool test_disable_blocking,
for (auto cred = credentials_types.begin(); cred != credentials_types.end();
++cred) {
for (auto msg = messages.begin(); msg != messages.end(); msg++) {
- scenarios.push_back(TestScenario(false, *cred, *msg));
+ scenarios.emplace_back(false, *cred, *msg);
if (test_disable_blocking) {
- scenarios.push_back(TestScenario(true, *cred, *msg));
+ scenarios.emplace_back(true, *cred, *msg);
}
}
}
diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc
index 81318866c9..9786350040 100644
--- a/test/cpp/end2end/end2end_test.cc
+++ b/test/cpp/end2end/end2end_test.cc
@@ -199,7 +199,10 @@ class TestScenario {
credentials_type.c_str());
}
bool use_proxy;
- const grpc::string credentials_type;
+ // Although the below grpc::string is logically const, we can't declare
+ // them const because of a limitation in the way old compilers (e.g., gcc-4.4)
+ // manage vector insertion using a copy constructor
+ grpc::string credentials_type;
};
class End2endTest : public ::testing::TestWithParam<TestScenario> {
@@ -1421,9 +1424,9 @@ std::vector<TestScenario> CreateTestScenarios(bool use_proxy,
}
for (auto it = credentials_types.begin(); it != credentials_types.end();
++it) {
- scenarios.push_back(TestScenario(false, *it));
+ scenarios.emplace_back(false, *it);
if (use_proxy) {
- scenarios.push_back(TestScenario(true, *it));
+ scenarios.emplace_back(true, *it);
}
}
return scenarios;