diff options
author | kosak <kosak@google.com> | 2014-11-17 02:28:09 +0000 |
---|---|---|
committer | kosak <kosak@google.com> | 2014-11-17 02:28:09 +0000 |
commit | e330b754cbd4b23a160521e05ff1014ed576378b (patch) | |
tree | 28b5e9e95b8aae5655a917c2e4ef9c0e7dbb989d /src | |
parent | 074ed8c8ea5732a71748e41e95e2d7e17d782302 (diff) | |
download | googletest-e330b754cbd4b23a160521e05ff1014ed576378b.tar.gz googletest-e330b754cbd4b23a160521e05ff1014ed576378b.tar.bz2 googletest-e330b754cbd4b23a160521e05ff1014ed576378b.zip |
Strip trailing whitespace when stringifying type lists.
Diffstat (limited to 'src')
-rw-r--r-- | src/gtest-typed-test.cc | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/gtest-typed-test.cc b/src/gtest-typed-test.cc index f0079f40..e11d050a 100644 --- a/src/gtest-typed-test.cc +++ b/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<std::string> tests; - for (const char* names = registered_tests; names != NULL; - names = SkipComma(names)) { - const std::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; |