Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include "gtest/gtest-typed-test.h"
00033 #include "gtest/gtest.h"
00034
00035 namespace testing {
00036 namespace internal {
00037
00038 #if GTEST_HAS_TYPED_TEST_P
00039
00040
00041
00042 static const char* SkipSpaces(const char* str) {
00043 while (IsSpace(*str))
00044 str++;
00045 return str;
00046 }
00047
00048
00049
00050
00051 const char* TypedTestCasePState::VerifyRegisteredTestNames(
00052 const char* file, int line, const char* registered_tests) {
00053 typedef ::std::set<const char*>::const_iterator DefinedTestIter;
00054 registered_ = true;
00055
00056
00057
00058 registered_tests = SkipSpaces(registered_tests);
00059
00060 Message errors;
00061 ::std::set<String> tests;
00062 for (const char* names = registered_tests; names != NULL;
00063 names = SkipComma(names)) {
00064 const String name = GetPrefixUntilComma(names);
00065 if (tests.count(name) != 0) {
00066 errors << "Test " << name << " is listed more than once.\n";
00067 continue;
00068 }
00069
00070 bool found = false;
00071 for (DefinedTestIter it = defined_test_names_.begin();
00072 it != defined_test_names_.end();
00073 ++it) {
00074 if (name == *it) {
00075 found = true;
00076 break;
00077 }
00078 }
00079
00080 if (found) {
00081 tests.insert(name);
00082 } else {
00083 errors << "No test named " << name
00084 << " can be found in this test case.\n";
00085 }
00086 }
00087
00088 for (DefinedTestIter it = defined_test_names_.begin();
00089 it != defined_test_names_.end();
00090 ++it) {
00091 if (tests.count(*it) == 0) {
00092 errors << "You forgot to list test " << *it << ".\n";
00093 }
00094 }
00095
00096 const String& errors_str = errors.GetString();
00097 if (errors_str != "") {
00098 fprintf(stderr, "%s %s", FormatFileLocation(file, line).c_str(),
00099 errors_str.c_str());
00100 fflush(stderr);
00101 posix::Abort();
00102 }
00103
00104 return registered_tests;
00105 }
00106
00107 #endif // GTEST_HAS_TYPED_TEST_P
00108
00109 }
00110 }