Verifies that registered_tests match the test names in registered_tests_; returns registered_tests if successful, or aborts the program otherwise.
| 11703 | // registered_tests_; returns registered_tests if successful, or |
| 11704 | // aborts the program otherwise. |
| 11705 | const char* TypedTestSuitePState::VerifyRegisteredTestNames( |
| 11706 | const char* file, int line, const char* registered_tests) { |
| 11707 | typedef RegisteredTestsMap::const_iterator RegisteredTestIter; |
| 11708 | registered_ = true; |
| 11709 | |
| 11710 | std::vector<std::string> name_vec = SplitIntoTestNames(registered_tests); |
| 11711 | |
| 11712 | Message errors; |
| 11713 | |
| 11714 | std::set<std::string> tests; |
| 11715 | for (std::vector<std::string>::const_iterator name_it = name_vec.begin(); |
| 11716 | name_it != name_vec.end(); ++name_it) { |
| 11717 | const std::string& name = *name_it; |
| 11718 | if (tests.count(name) != 0) { |
| 11719 | errors << "Test " << name << " is listed more than once.\n"; |
| 11720 | continue; |
| 11721 | } |
| 11722 | |
| 11723 | bool found = false; |
| 11724 | for (RegisteredTestIter it = registered_tests_.begin(); |
| 11725 | it != registered_tests_.end(); |
| 11726 | ++it) { |
| 11727 | if (name == it->first) { |
| 11728 | found = true; |
| 11729 | break; |
| 11730 | } |
| 11731 | } |
| 11732 | |
| 11733 | if (found) { |
| 11734 | tests.insert(name); |
| 11735 | } else { |
| 11736 | errors << "No test named " << name |
| 11737 | << " can be found in this test suite.\n"; |
| 11738 | } |
| 11739 | } |
| 11740 | |
| 11741 | for (RegisteredTestIter it = registered_tests_.begin(); |
| 11742 | it != registered_tests_.end(); |
| 11743 | ++it) { |
| 11744 | if (tests.count(it->first) == 0) { |
| 11745 | errors << "You forgot to list test " << it->first << ".\n"; |
| 11746 | } |
| 11747 | } |
| 11748 | |
| 11749 | const std::string& errors_str = errors.GetString(); |
| 11750 | if (errors_str != "") { |
| 11751 | fprintf(stderr, "%s %s", FormatFileLocation(file, line).c_str(), |
| 11752 | errors_str.c_str()); |
| 11753 | fflush(stderr); |
| 11754 | posix::Abort(); |
| 11755 | } |
| 11756 | |
| 11757 | return registered_tests; |
| 11758 | } |
| 11759 | |
| 11760 | #endif // GTEST_HAS_TYPED_TEST_P |
| 11761 |
nothing calls this directly
no test coverage detected