aboutsummaryrefslogtreecommitdiff
path: root/tests/gtest/src/gtest-typed-test.cc
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2015-03-24 08:48:43 +0200
committerRiccardo Spagni <ric@spagni.net>2015-03-24 08:48:43 +0200
commit1c49d6b2d392f67df18cfa8103584957c1bfe562 (patch)
treeeed9fa17abebf81016c6d569051350c747ebdd74 /tests/gtest/src/gtest-typed-test.cc
parentMerge pull request #238 (diff)
downloadmonero-1c49d6b2d392f67df18cfa8103584957c1bfe562.tar.xz
updated gtest to latest
Diffstat (limited to 'tests/gtest/src/gtest-typed-test.cc')
-rw-r--r--tests/gtest/src/gtest-typed-test.cc24
1 files changed, 16 insertions, 8 deletions
diff --git a/tests/gtest/src/gtest-typed-test.cc b/tests/gtest/src/gtest-typed-test.cc
index a5cc88f92..e11d050a4 100644
--- a/tests/gtest/src/gtest-typed-test.cc
+++ b/tests/gtest/src/gtest-typed-test.cc
@@ -45,6 +45,15 @@ static const char* SkipSpaces(const char* str) {
return str;
}
+static std::vector<std::string> SplitIntoTestNames(const char* src) {
+ std::vector<std::string> name_vec;
+ src = SkipSpaces(src);
+ for (; src != NULL; src = SkipComma(src)) {
+ name_vec.push_back(StripTrailingSpaces(GetPrefixUntilComma(src)));
+ }
+ return name_vec;
+}
+
// Verifies that registered_tests match the test names in
// defined_test_names_; returns registered_tests if successful, or
// aborts the program otherwise.
@@ -53,15 +62,14 @@ const char* TypedTestCasePState::VerifyRegisteredTestNames(
typedef ::std::set<const char*>::const_iterator DefinedTestIter;
registered_ = true;
- // Skip initial whitespace in registered_tests since some
- // preprocessors prefix stringizied literals with whitespace.
- registered_tests = SkipSpaces(registered_tests);
+ std::vector<std::string> name_vec = SplitIntoTestNames(registered_tests);
Message errors;
- ::std::set<String> tests;
- for (const char* names = registered_tests; names != NULL;
- names = SkipComma(names)) {
- const String name = GetPrefixUntilComma(names);
+
+ std::set<std::string> tests;
+ for (std::vector<std::string>::const_iterator name_it = name_vec.begin();
+ name_it != name_vec.end(); ++name_it) {
+ const std::string& name = *name_it;
if (tests.count(name) != 0) {
errors << "Test " << name << " is listed more than once.\n";
continue;
@@ -93,7 +101,7 @@ const char* TypedTestCasePState::VerifyRegisteredTestNames(
}
}
- const String& errors_str = errors.GetString();
+ const std::string& errors_str = errors.GetString();
if (errors_str != "") {
fprintf(stderr, "%s %s", FormatFileLocation(file, line).c_str(),
errors_str.c_str());