Googletest export
Add option (default to disabled) to make C++ type parameterized tests (TYPED_TEST_P) fail when they're not instantiated. When an un-instantiated TYPED_TEST_P is found, a new test will be inserted that emits a suitable message. For now, that is just a notice, but the hope it to flip the bit to make it fail by default. PiperOrigin-RevId: 286408038
This commit is contained in:
		@@ -617,8 +617,9 @@ class GTEST_API_ TypedTestSuitePState {
 | 
			
		||||
  // Verifies that registered_tests match the test names in
 | 
			
		||||
  // defined_test_names_; returns registered_tests if successful, or
 | 
			
		||||
  // aborts the program otherwise.
 | 
			
		||||
  const char* VerifyRegisteredTestNames(
 | 
			
		||||
      const char* file, int line, const char* registered_tests);
 | 
			
		||||
  const char* VerifyRegisteredTestNames(const char* test_suite_name,
 | 
			
		||||
                                        const char* file, int line,
 | 
			
		||||
                                        const char* registered_tests);
 | 
			
		||||
 | 
			
		||||
 private:
 | 
			
		||||
  typedef ::std::map<std::string, CodeLocation> RegisteredTestsMap;
 | 
			
		||||
@@ -750,6 +751,11 @@ class TypeParameterizedTest<Fixture, TestSel, internal::None> {
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
GTEST_API_ void RegisterTypeParameterizedTestSuite(const char* test_suite_name,
 | 
			
		||||
                                                   CodeLocation code_location);
 | 
			
		||||
GTEST_API_ void RegisterTypeParameterizedTestSuiteInstantiation(
 | 
			
		||||
    const char* case_name);
 | 
			
		||||
 | 
			
		||||
// TypeParameterizedTestSuite<Fixture, Tests, Types>::Register()
 | 
			
		||||
// registers *all combinations* of 'Tests' and 'Types' with Google
 | 
			
		||||
// Test.  The return value is insignificant - we just need to return
 | 
			
		||||
@@ -762,6 +768,7 @@ class TypeParameterizedTestSuite {
 | 
			
		||||
                       const char* test_names,
 | 
			
		||||
                       const std::vector<std::string>& type_names =
 | 
			
		||||
                           GenerateNames<DefaultNameGenerator, Types>()) {
 | 
			
		||||
    RegisterTypeParameterizedTestSuiteInstantiation(case_name);
 | 
			
		||||
    std::string test_name = StripTrailingSpaces(
 | 
			
		||||
        GetPrefixUntilComma(test_names));
 | 
			
		||||
    if (!state->TestExists(test_name)) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user