MCPcopy Create free account
hub / github.com/OpenPTrack/open_ptrack_v2 / VerifyRegisteredTestNames

Method VerifyRegisteredTestNames

rtpose_wrapper/src/gtest/gtest-all.cpp:9058–9112  ·  view source on GitHub ↗

Verifies that registered_tests match the test names in defined_test_names_; returns registered_tests if successful, or aborts the program otherwise.

Source from the content-addressed store, hash-verified

9056// defined_test_names_; returns registered_tests if successful, or
9057// aborts the program otherwise.
9058const char* TypedTestCasePState::VerifyRegisteredTestNames(
9059 const char* file, int line, const char* registered_tests) {
9060 typedef ::std::set<const char*>::const_iterator DefinedTestIter;
9061 registered_ = true;
9062
9063 // Skip initial whitespace in registered_tests since some
9064 // preprocessors prefix stringizied literals with whitespace.
9065 registered_tests = SkipSpaces(registered_tests);
9066
9067 Message errors;
9068 ::std::set<String> tests;
9069 for (const char* names = registered_tests; names != NULL;
9070 names = SkipComma(names)) {
9071 const String name = GetPrefixUntilComma(names);
9072 if (tests.count(name) != 0) {
9073 errors << "Test " << name << " is listed more than once.\n";
9074 continue;
9075 }
9076
9077 bool found = false;
9078 for (DefinedTestIter it = defined_test_names_.begin();
9079 it != defined_test_names_.end();
9080 ++it) {
9081 if (name == *it) {
9082 found = true;
9083 break;
9084 }
9085 }
9086
9087 if (found) {
9088 tests.insert(name);
9089 } else {
9090 errors << "No test named " << name
9091 << " can be found in this test case.\n";
9092 }
9093 }
9094
9095 for (DefinedTestIter it = defined_test_names_.begin();
9096 it != defined_test_names_.end();
9097 ++it) {
9098 if (tests.count(*it) == 0) {
9099 errors << "You forgot to list test " << *it << ".\n";
9100 }
9101 }
9102
9103 const String& errors_str = errors.GetString();
9104 if (errors_str != "") {
9105 fprintf(stderr, "%s %s", FormatFileLocation(file, line).c_str(),
9106 errors_str.c_str());
9107 fflush(stderr);
9108 posix::Abort();
9109 }
9110
9111 return registered_tests;
9112}
9113
9114#endif // GTEST_HAS_TYPED_TEST_P
9115

Callers

nothing calls this directly

Calls 8

SkipSpacesFunction · 0.85
SkipCommaFunction · 0.85
GetPrefixUntilCommaFunction · 0.85
FormatFileLocationFunction · 0.85
countMethod · 0.80
AbortFunction · 0.70
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected