Verifies that registered_tests match the test names in defined_test_names_; returns registered_tests if successful, or aborts the program otherwise.
| 10376 | // defined_test_names_; returns registered_tests if successful, or |
| 10377 | // aborts the program otherwise. |
| 10378 | const char* TypedTestCasePState::VerifyRegisteredTestNames( |
| 10379 | const char* file, int line, const char* registered_tests) { |
| 10380 | typedef ::std::set<const char*>::const_iterator DefinedTestIter; |
| 10381 | registered_ = true; |
| 10382 | |
| 10383 | std::vector<std::string> name_vec = SplitIntoTestNames(registered_tests); |
| 10384 | |
| 10385 | Message errors; |
| 10386 | |
| 10387 | std::set<std::string> tests; |
| 10388 | for (std::vector<std::string>::const_iterator name_it = name_vec.begin(); |
| 10389 | name_it != name_vec.end(); ++name_it) { |
| 10390 | const std::string& name = *name_it; |
| 10391 | if (tests.count(name) != 0) { |
| 10392 | errors << "Test " << name << " is listed more than once.\n"; |
| 10393 | continue; |
| 10394 | } |
| 10395 | |
| 10396 | bool found = false; |
| 10397 | for (DefinedTestIter it = defined_test_names_.begin(); |
| 10398 | it != defined_test_names_.end(); |
| 10399 | ++it) { |
| 10400 | if (name == *it) { |
| 10401 | found = true; |
| 10402 | break; |
| 10403 | } |
| 10404 | } |
| 10405 | |
| 10406 | if (found) { |
| 10407 | tests.insert(name); |
| 10408 | } else { |
| 10409 | errors << "No test named " << name |
| 10410 | << " can be found in this test case.\n"; |
| 10411 | } |
| 10412 | } |
| 10413 | |
| 10414 | for (DefinedTestIter it = defined_test_names_.begin(); |
| 10415 | it != defined_test_names_.end(); |
| 10416 | ++it) { |
| 10417 | if (tests.count(*it) == 0) { |
| 10418 | errors << "You forgot to list test " << *it << ".\n"; |
| 10419 | } |
| 10420 | } |
| 10421 | |
| 10422 | const std::string& errors_str = errors.GetString(); |
| 10423 | if (errors_str != "") { |
| 10424 | fprintf(stderr, "%s %s", FormatFileLocation(file, line).c_str(), |
| 10425 | errors_str.c_str()); |
| 10426 | fflush(stderr); |
| 10427 | posix::Abort(); |
| 10428 | } |
| 10429 | |
| 10430 | return registered_tests; |
| 10431 | } |
| 10432 | |
| 10433 | #endif // GTEST_HAS_TYPED_TEST_P |
| 10434 |
nothing calls this directly
no test coverage detected