Googletest export

Remove uses of GTEST_HAS_TYPED_TEST_P and GTEST_HAS_TYPED_TEST.

PiperOrigin-RevId: 353935996
This commit is contained in:
Abseil Team 2021-01-26 13:24:04 -08:00 committed by Dino Radaković
parent 273f8cb059
commit d114398800
19 changed files with 22 additions and 192 deletions

View File

@ -33,8 +33,8 @@
// GOOGLETEST_CM0002 DO NOT DELETE // GOOGLETEST_CM0002 DO NOT DELETE
#ifndef THIRD_PARTY_GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_FUNCTION_MOCKER_H_ // NOLINT #ifndef GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_FUNCTION_MOCKER_H_ // NOLINT
#define THIRD_PARTY_GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_FUNCTION_MOCKER_H_ // NOLINT #define GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_FUNCTION_MOCKER_H_ // NOLINT
#include <type_traits> // IWYU pragma: keep #include <type_traits> // IWYU pragma: keep
#include <utility> // IWYU pragma: keep #include <utility> // IWYU pragma: keep
@ -476,4 +476,4 @@ using internal::FunctionMocker;
#define GMOCK_MOCKER_(arity, constness, Method) \ #define GMOCK_MOCKER_(arity, constness, Method) \
GTEST_CONCAT_TOKEN_(gmock##constness##arity##_##Method##_, __LINE__) GTEST_CONCAT_TOKEN_(gmock##constness##arity##_##Method##_, __LINE__)
#endif // THIRD_PARTY_GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_FUNCTION_MOCKER_H_ #endif // GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_FUNCTION_MOCKER_H_

View File

@ -1,5 +1,5 @@
#ifndef THIRD_PARTY_GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_PP_H_ #ifndef GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_PP_H_
#define THIRD_PARTY_GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_PP_H_ #define GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_PP_H_
// Expands and concatenates the arguments. Constructed macros reevaluate. // Expands and concatenates the arguments. Constructed macros reevaluate.
#define GMOCK_PP_CAT(_1, _2) GMOCK_PP_INTERNAL_CAT(_1, _2) #define GMOCK_PP_CAT(_1, _2) GMOCK_PP_INTERNAL_CAT(_1, _2)
@ -276,4 +276,4 @@
GMOCK_PP_INTERNAL_FOR_EACH_IMPL_14(GMOCK_PP_INC(_i), _Macro, _Data, \ GMOCK_PP_INTERNAL_FOR_EACH_IMPL_14(GMOCK_PP_INC(_i), _Macro, _Data, \
(GMOCK_PP_TAIL _Tuple)) (GMOCK_PP_TAIL _Tuple))
#endif // THIRD_PARTY_GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PP_H_ #endif // GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PP_H_

View File

@ -1,16 +0,0 @@
#include "gmock/gmock.h"
#include <memory>
#include <string>
#if defined(TEST_MOCK_METHOD_INVALID_CONST_SPEC)
struct Base {
MOCK_METHOD(int, F, (), (onst));
};
#else
// Sanity check - this should compile.
#endif

View File

@ -1,43 +0,0 @@
"""Negative compilation tests for Google Mock macro MOCK_METHOD."""
import os
import sys
IS_LINUX = os.name == "posix" and os.uname()[0] == "Linux"
if not IS_LINUX:
sys.stderr.write(
"WARNING: Negative compilation tests are not supported on this platform")
sys.exit(0)
# Suppresses the 'Import not at the top of the file' lint complaint.
# pylint: disable-msg=C6204
from google3.testing.pybase import fake_target_util
from google3.testing.pybase import googletest
# pylint: enable-msg=C6204
class GMockMethodNCTest(googletest.TestCase):
"""Negative compilation tests for MOCK_METHOD."""
# The class body is intentionally empty. The actual test*() methods
# will be defined at run time by a call to
# DefineNegativeCompilationTests() later.
pass
# Defines a list of test specs, where each element is a tuple
# (test name, list of regexes for matching the compiler errors).
TEST_SPECS = [
("MOCK_METHOD_INVALID_CONST_SPEC",
[r"onst cannot be recognized as a valid specification modifier"]),
]
# Define a test method in GMockNCTest for each element in TEST_SPECS.
fake_target_util.DefineNegativeCompilationTests(
GMockMethodNCTest,
"google3/third_party/googletest/googlemock/test/gmock-function-mocker_nc",
"gmock-function-mocker_nc.o", TEST_SPECS)
if __name__ == "__main__":
googletest.main()

View File

@ -175,8 +175,6 @@ INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes);
// Implements typed tests. // Implements typed tests.
#if GTEST_HAS_TYPED_TEST
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
// //
// Expands to the name of the typedef for the type parameters of the // Expands to the name of the typedef for the type parameters of the
@ -230,12 +228,8 @@ INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes);
TYPED_TEST_SUITE TYPED_TEST_SUITE
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_ #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
#endif // GTEST_HAS_TYPED_TEST
// Implements type-parameterized tests. // Implements type-parameterized tests.
#if GTEST_HAS_TYPED_TEST_P
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
// //
// Expands to the namespace name that the type-parameterized tests for // Expands to the namespace name that the type-parameterized tests for
@ -332,6 +326,4 @@ INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes);
INSTANTIATE_TYPED_TEST_SUITE_P INSTANTIATE_TYPED_TEST_SUITE_P
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_ #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
#endif // GTEST_HAS_TYPED_TEST_P
#endif // GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_ #endif // GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_

View File

@ -590,8 +590,6 @@ GTEST_API_ TestInfo* MakeAndRegisterTestInfo(
// and returns false. None of pstr, *pstr, and prefix can be NULL. // and returns false. None of pstr, *pstr, and prefix can be NULL.
GTEST_API_ bool SkipPrefix(const char* prefix, const char** pstr); GTEST_API_ bool SkipPrefix(const char* prefix, const char** pstr);
#if GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \ GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
/* class A needs to have dll-interface to be used by clients of class B */) /* class A needs to have dll-interface to be used by clients of class B */)
@ -823,8 +821,6 @@ class TypeParameterizedTestSuite<Fixture, internal::None, Types> {
} }
}; };
#endif // GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P
// Returns the current OS stack trace as an std::string. // Returns the current OS stack trace as an std::string.
// //
// The maximum number of stack frames to be included is specified by // The maximum number of stack frames to be included is specified by

View File

@ -98,8 +98,6 @@ std::string GetTypeName() {
#endif // GTEST_HAS_RTTI #endif // GTEST_HAS_RTTI
} }
#if GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P
// A unique type indicating an empty node // A unique type indicating an empty node
struct None {}; struct None {};
@ -175,8 +173,6 @@ struct GenerateTypeList {
using type = typename proxy::type; using type = typename proxy::type;
}; };
#endif // GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P
} // namespace internal } // namespace internal
template <typename... Ts> template <typename... Ts>

View File

@ -73,8 +73,6 @@ class PrimeTableTest : public testing::Test {
PrimeTable* const table_; PrimeTable* const table_;
}; };
#if GTEST_HAS_TYPED_TEST
using testing::Types; using testing::Types;
// Google Test offers two ways for reusing tests for different types. // Google Test offers two ways for reusing tests for different types.
@ -134,10 +132,6 @@ TYPED_TEST(PrimeTableTest, CanGetNextPrime) {
// in the type list specified in TYPED_TEST_SUITE. Sit back and be // in the type list specified in TYPED_TEST_SUITE. Sit back and be
// happy that you don't have to define them multiple times. // happy that you don't have to define them multiple times.
#endif // GTEST_HAS_TYPED_TEST
#if GTEST_HAS_TYPED_TEST_P
using testing::Types; using testing::Types;
// Sometimes, however, you don't yet know all the types that you want // Sometimes, however, you don't yet know all the types that you want
@ -220,5 +214,4 @@ INSTANTIATE_TYPED_TEST_SUITE_P(OnTheFlyAndPreCalculated, // Instance name
PrimeTableTest2, // Test case name PrimeTableTest2, // Test case name
PrimeTableImplementations); // Type list PrimeTableImplementations); // Type list
#endif // GTEST_HAS_TYPED_TEST_P
} // namespace } // namespace

View File

@ -35,8 +35,6 @@
namespace testing { namespace testing {
namespace internal { namespace internal {
#if GTEST_HAS_TYPED_TEST_P
// Skips to the first non-space char in str. Returns an empty string if str // Skips to the first non-space char in str. Returns an empty string if str
// contains only whitespace characters. // contains only whitespace characters.
static const char* SkipSpaces(const char* str) { static const char* SkipSpaces(const char* str) {
@ -105,7 +103,5 @@ const char* TypedTestSuitePState::VerifyRegisteredTestNames(
return registered_tests; return registered_tests;
} }
#endif // GTEST_HAS_TYPED_TEST_P
} // namespace internal } // namespace internal
} // namespace testing } // namespace testing

View File

@ -744,9 +744,6 @@ TEST_P(DetectNotInstantiatedTest, Used) { }
// This would make the test failure from the above go away. // This would make the test failure from the above go away.
// INSTANTIATE_TEST_SUITE_P(Fix, DetectNotInstantiatedTest, testing::Values(1)); // INSTANTIATE_TEST_SUITE_P(Fix, DetectNotInstantiatedTest, testing::Values(1));
// This #ifdef block tests the output of typed tests.
#if GTEST_HAS_TYPED_TEST
template <typename T> template <typename T>
class TypedTest : public testing::Test { class TypedTest : public testing::Test {
}; };
@ -783,11 +780,6 @@ TYPED_TEST(TypedTestWithNames, Success) {}
TYPED_TEST(TypedTestWithNames, Failure) { FAIL(); } TYPED_TEST(TypedTestWithNames, Failure) { FAIL(); }
#endif // GTEST_HAS_TYPED_TEST
// This #ifdef block tests the output of type-parameterized tests.
#if GTEST_HAS_TYPED_TEST_P
template <typename T> template <typename T>
class TypedTestP : public testing::Test { class TypedTestP : public testing::Test {
}; };
@ -838,8 +830,6 @@ REGISTER_TYPED_TEST_SUITE_P(DetectNotInstantiatedTypesTest, Used);
// typedef ::testing::Types<char, int, unsigned int> MyTypes; // typedef ::testing::Types<char, int, unsigned int> MyTypes;
// INSTANTIATE_TYPED_TEST_SUITE_P(All, DetectNotInstantiatedTypesTest, MyTypes); // INSTANTIATE_TYPED_TEST_SUITE_P(All, DetectNotInstantiatedTypesTest, MyTypes);
#endif // GTEST_HAS_TYPED_TEST_P
#if GTEST_HAS_DEATH_TEST #if GTEST_HAS_DEATH_TEST
// We rely on the golden file to verify that tests whose test case // We rely on the golden file to verify that tests whose test case
@ -848,8 +838,6 @@ REGISTER_TYPED_TEST_SUITE_P(DetectNotInstantiatedTypesTest, Used);
TEST(ADeathTest, ShouldRunFirst) { TEST(ADeathTest, ShouldRunFirst) {
} }
# if GTEST_HAS_TYPED_TEST
// We rely on the golden file to verify that typed tests whose test // We rely on the golden file to verify that typed tests whose test
// case name ends with DeathTest are run first. // case name ends with DeathTest are run first.
@ -863,10 +851,6 @@ TYPED_TEST_SUITE(ATypedDeathTest, NumericTypes);
TYPED_TEST(ATypedDeathTest, ShouldRunFirst) { TYPED_TEST(ATypedDeathTest, ShouldRunFirst) {
} }
# endif // GTEST_HAS_TYPED_TEST
# if GTEST_HAS_TYPED_TEST_P
// We rely on the golden file to verify that type-parameterized tests // We rely on the golden file to verify that type-parameterized tests
// whose test case name ends with DeathTest are run first. // whose test case name ends with DeathTest are run first.
@ -884,8 +868,6 @@ REGISTER_TYPED_TEST_SUITE_P(ATypeParamDeathTest, ShouldRunFirst);
INSTANTIATE_TYPED_TEST_SUITE_P(My, ATypeParamDeathTest, NumericTypes); INSTANTIATE_TYPED_TEST_SUITE_P(My, ATypeParamDeathTest, NumericTypes);
# endif // GTEST_HAS_TYPED_TEST_P
#endif // GTEST_HAS_DEATH_TEST #endif // GTEST_HAS_DEATH_TEST
// Tests various failure conditions of // Tests various failure conditions of

View File

@ -373,8 +373,6 @@ TEST(RegexEngineSelectionTest, SelectsCorrectRegexEngine) {
#if GTEST_USES_POSIX_RE #if GTEST_USES_POSIX_RE
# if GTEST_HAS_TYPED_TEST
template <typename Str> template <typename Str>
class RETest : public ::testing::Test {}; class RETest : public ::testing::Test {};
@ -430,8 +428,6 @@ TYPED_TEST(RETest, PartialMatchWorks) {
EXPECT_FALSE(RE::PartialMatch(TypeParam("zza"), re)); EXPECT_FALSE(RE::PartialMatch(TypeParam("zza"), re));
} }
# endif // GTEST_HAS_TYPED_TEST
#elif GTEST_USES_SIMPLE_RE #elif GTEST_USES_SIMPLE_RE
TEST(IsInSetTest, NulCharIsNotInAnySet) { TEST(IsInSetTest, NulCharIsNotInAnySet) {

View File

@ -33,12 +33,8 @@
#include "test/gtest-typed-test_test.h" #include "test/gtest-typed-test_test.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
#if GTEST_HAS_TYPED_TEST_P
// Tests that the same type-parameterized test case can be // Tests that the same type-parameterized test case can be
// instantiated in different translation units linked together. // instantiated in different translation units linked together.
// (ContainerTest is also instantiated in gtest-typed-test_test.cc.) // (ContainerTest is also instantiated in gtest-typed-test_test.cc.)
INSTANTIATE_TYPED_TEST_SUITE_P(Vector, ContainerTest, INSTANTIATE_TYPED_TEST_SUITE_P(Vector, ContainerTest,
testing::Types<std::vector<int> >); testing::Types<std::vector<int> >);
#endif // GTEST_HAS_TYPED_TEST_P

View File

@ -88,9 +88,6 @@ class CommonTest : public Test {
template <typename T> template <typename T>
T* CommonTest<T>::shared_ = nullptr; T* CommonTest<T>::shared_ = nullptr;
// This #ifdef block tests typed tests.
#if GTEST_HAS_TYPED_TEST
using testing::Types; using testing::Types;
// Tests that SetUpTestSuite()/TearDownTestSuite(), fixture ctor/dtor, // Tests that SetUpTestSuite()/TearDownTestSuite(), fixture ctor/dtor,
@ -204,11 +201,6 @@ TYPED_TEST(TypedTestWithNames, TestSuiteName) {
} }
} }
#endif // GTEST_HAS_TYPED_TEST
// This #ifdef block tests type-parameterized tests.
#if GTEST_HAS_TYPED_TEST_P
using testing::Types; using testing::Types;
using testing::internal::TypedTestSuitePState; using testing::internal::TypedTestSuitePState;
@ -443,20 +435,3 @@ INSTANTIATE_TYPED_TEST_SUITE_P(My, TrimmedTest, TrimTypes);
} // namespace library2 } // namespace library2
#endif // GTEST_HAS_TYPED_TEST_P
#if !defined(GTEST_HAS_TYPED_TEST) && !defined(GTEST_HAS_TYPED_TEST_P)
// Google Test may not support type-parameterized tests with some
// compilers. If we use conditional compilation to compile out all
// code referring to the gtest_main library, MSVC linker will not link
// that library at all and consequently complain about missing entry
// point defined in that library (fatal error LNK1561: entry point
// must be defined). This dummy test keeps gtest_main linked in.
TEST(DummyTest, TypedTestsAreNotSupportedOnThisPlatform) {}
#if _MSC_VER
GTEST_DISABLE_MSC_WARNINGS_POP_() // 4127
#endif // _MSC_VER
#endif // #if !defined(GTEST_HAS_TYPED_TEST) && !defined(GTEST_HAS_TYPED_TEST_P)

View File

@ -33,8 +33,6 @@
#include "gtest/gtest.h" #include "gtest/gtest.h"
#if GTEST_HAS_TYPED_TEST_P
using testing::Test; using testing::Test;
// For testing that the same type-parameterized test case can be // For testing that the same type-parameterized test case can be
@ -60,6 +58,4 @@ TYPED_TEST_P(ContainerTest, InitialSizeIsZero) {
REGISTER_TYPED_TEST_SUITE_P(ContainerTest, REGISTER_TYPED_TEST_SUITE_P(ContainerTest,
CanBeDefaultConstructed, InitialSizeIsZero); CanBeDefaultConstructed, InitialSizeIsZero);
#endif // GTEST_HAS_TYPED_TEST_P
#endif // GTEST_TEST_GTEST_TYPED_TEST_TEST_H_ #endif // GTEST_TEST_GTEST_TYPED_TEST_TEST_H_

View File

@ -95,17 +95,12 @@ class UnitTestHelper {
} }
}; };
#if GTEST_HAS_TYPED_TEST
template <typename T> class TestSuiteWithCommentTest : public Test {}; template <typename T> class TestSuiteWithCommentTest : public Test {};
TYPED_TEST_SUITE(TestSuiteWithCommentTest, Types<int>); TYPED_TEST_SUITE(TestSuiteWithCommentTest, Types<int>);
TYPED_TEST(TestSuiteWithCommentTest, Dummy) {} TYPED_TEST(TestSuiteWithCommentTest, Dummy) {}
const int kTypedTestSuites = 1; const int kTypedTestSuites = 1;
const int kTypedTests = 1; const int kTypedTests = 1;
#else
const int kTypedTestSuites = 0;
const int kTypedTests = 0;
#endif // GTEST_HAS_TYPED_TEST
// We can only test the accessors that do not change value while tests run. // We can only test the accessors that do not change value while tests run.
// Since tests can be run in any order, the values the accessors that track // Since tests can be run in any order, the values the accessors that track
@ -123,9 +118,7 @@ TEST(ApiTest, UnitTestImmutableAccessorsWork) {
EXPECT_STREQ("ApiTest", test_suites[0]->name()); EXPECT_STREQ("ApiTest", test_suites[0]->name());
EXPECT_STREQ("DISABLED_Test", test_suites[1]->name()); EXPECT_STREQ("DISABLED_Test", test_suites[1]->name());
#if GTEST_HAS_TYPED_TEST
EXPECT_STREQ("TestSuiteWithCommentTest/0", test_suites[2]->name()); EXPECT_STREQ("TestSuiteWithCommentTest/0", test_suites[2]->name());
#endif // GTEST_HAS_TYPED_TEST
delete[] test_suites; delete[] test_suites;
@ -183,7 +176,6 @@ TEST(ApiTest, TestSuiteImmutableAccessorsWork) {
delete[] tests; delete[] tests;
tests = nullptr; tests = nullptr;
#if GTEST_HAS_TYPED_TEST
test_suite = UnitTestHelper::FindTestSuite("TestSuiteWithCommentTest/0"); test_suite = UnitTestHelper::FindTestSuite("TestSuiteWithCommentTest/0");
ASSERT_TRUE(test_suite != nullptr); ASSERT_TRUE(test_suite != nullptr);
@ -203,7 +195,6 @@ TEST(ApiTest, TestSuiteImmutableAccessorsWork) {
EXPECT_TRUE(tests[0]->should_run()); EXPECT_TRUE(tests[0]->should_run());
delete[] tests; delete[] tests;
#endif // GTEST_HAS_TYPED_TEST
} }
TEST(ApiTest, TestSuiteDisabledAccessorsWork) { TEST(ApiTest, TestSuiteDisabledAccessorsWork) {
@ -263,7 +254,6 @@ class FinalSuccessChecker : public Environment {
EXPECT_EQ(0, test_suites[1]->successful_test_count()); EXPECT_EQ(0, test_suites[1]->successful_test_count());
EXPECT_EQ(0, test_suites[1]->failed_test_count()); EXPECT_EQ(0, test_suites[1]->failed_test_count());
#if GTEST_HAS_TYPED_TEST
EXPECT_STREQ("TestSuiteWithCommentTest/0", test_suites[2]->name()); EXPECT_STREQ("TestSuiteWithCommentTest/0", test_suites[2]->name());
EXPECT_STREQ(GetTypeName<Types<int>>().c_str(), EXPECT_STREQ(GetTypeName<Types<int>>().c_str(),
test_suites[2]->type_param()); test_suites[2]->type_param());
@ -274,7 +264,6 @@ class FinalSuccessChecker : public Environment {
EXPECT_EQ(0, test_suites[2]->failed_test_count()); EXPECT_EQ(0, test_suites[2]->failed_test_count());
EXPECT_TRUE(test_suites[2]->Passed()); EXPECT_TRUE(test_suites[2]->Passed());
EXPECT_FALSE(test_suites[2]->Failed()); EXPECT_FALSE(test_suites[2]->Failed());
#endif // GTEST_HAS_TYPED_TEST
const TestSuite* test_suite = UnitTestHelper::FindTestSuite("ApiTest"); const TestSuite* test_suite = UnitTestHelper::FindTestSuite("ApiTest");
const TestInfo** tests = UnitTestHelper::GetSortedTests(test_suite); const TestInfo** tests = UnitTestHelper::GetSortedTests(test_suite);
@ -311,7 +300,6 @@ class FinalSuccessChecker : public Environment {
delete[] tests; delete[] tests;
#if GTEST_HAS_TYPED_TEST
test_suite = UnitTestHelper::FindTestSuite("TestSuiteWithCommentTest/0"); test_suite = UnitTestHelper::FindTestSuite("TestSuiteWithCommentTest/0");
tests = UnitTestHelper::GetSortedTests(test_suite); tests = UnitTestHelper::GetSortedTests(test_suite);
@ -324,7 +312,6 @@ class FinalSuccessChecker : public Environment {
EXPECT_EQ(0, tests[0]->result()->test_property_count()); EXPECT_EQ(0, tests[0]->result()->test_property_count());
delete[] tests; delete[] tests;
#endif // GTEST_HAS_TYPED_TEST
delete[] test_suites; delete[] test_suites;
} }
}; };

View File

@ -56,20 +56,20 @@ EXPECTED_XML = """<\?xml version="1.0" encoding="UTF-8"\?>
<testcase name="Test4" file=".*gtest_list_output_unittest_.cc" line="49" /> <testcase name="Test4" file=".*gtest_list_output_unittest_.cc" line="49" />
</testsuite> </testsuite>
<testsuite name="TypedTest/0" tests="2"> <testsuite name="TypedTest/0" tests="2">
<testcase name="Test7" type_param="int" file=".*gtest_list_output_unittest_.cc" line="61" /> <testcase name="Test7" type_param="int" file=".*gtest_list_output_unittest_.cc" line="60" />
<testcase name="Test8" type_param="int" file=".*gtest_list_output_unittest_.cc" line="62" /> <testcase name="Test8" type_param="int" file=".*gtest_list_output_unittest_.cc" line="61" />
</testsuite> </testsuite>
<testsuite name="TypedTest/1" tests="2"> <testsuite name="TypedTest/1" tests="2">
<testcase name="Test7" type_param="bool" file=".*gtest_list_output_unittest_.cc" line="61" /> <testcase name="Test7" type_param="bool" file=".*gtest_list_output_unittest_.cc" line="60" />
<testcase name="Test8" type_param="bool" file=".*gtest_list_output_unittest_.cc" line="62" /> <testcase name="Test8" type_param="bool" file=".*gtest_list_output_unittest_.cc" line="61" />
</testsuite> </testsuite>
<testsuite name="Single/TypeParameterizedTestSuite/0" tests="2"> <testsuite name="Single/TypeParameterizedTestSuite/0" tests="2">
<testcase name="Test9" type_param="int" file=".*gtest_list_output_unittest_.cc" line="69" /> <testcase name="Test9" type_param="int" file=".*gtest_list_output_unittest_.cc" line="66" />
<testcase name="Test10" type_param="int" file=".*gtest_list_output_unittest_.cc" line="70" /> <testcase name="Test10" type_param="int" file=".*gtest_list_output_unittest_.cc" line="67" />
</testsuite> </testsuite>
<testsuite name="Single/TypeParameterizedTestSuite/1" tests="2"> <testsuite name="Single/TypeParameterizedTestSuite/1" tests="2">
<testcase name="Test9" type_param="bool" file=".*gtest_list_output_unittest_.cc" line="69" /> <testcase name="Test9" type_param="bool" file=".*gtest_list_output_unittest_.cc" line="66" />
<testcase name="Test10" type_param="bool" file=".*gtest_list_output_unittest_.cc" line="70" /> <testcase name="Test10" type_param="bool" file=".*gtest_list_output_unittest_.cc" line="67" />
</testsuite> </testsuite>
<testsuite name="ValueParam/ValueParamTest" tests="4"> <testsuite name="ValueParam/ValueParamTest" tests="4">
<testcase name="Test5/0" value_param="33" file=".*gtest_list_output_unittest_.cc" line="52" /> <testcase name="Test5/0" value_param="33" file=".*gtest_list_output_unittest_.cc" line="52" />
@ -124,13 +124,13 @@ EXPECTED_JSON = """{
"name": "Test7", "name": "Test7",
"type_param": "int", "type_param": "int",
"file": ".*gtest_list_output_unittest_.cc", "file": ".*gtest_list_output_unittest_.cc",
"line": 61 "line": 60
}, },
{ {
"name": "Test8", "name": "Test8",
"type_param": "int", "type_param": "int",
"file": ".*gtest_list_output_unittest_.cc", "file": ".*gtest_list_output_unittest_.cc",
"line": 62 "line": 61
} }
\] \]
}, },
@ -142,13 +142,13 @@ EXPECTED_JSON = """{
"name": "Test7", "name": "Test7",
"type_param": "bool", "type_param": "bool",
"file": ".*gtest_list_output_unittest_.cc", "file": ".*gtest_list_output_unittest_.cc",
"line": 61 "line": 60
}, },
{ {
"name": "Test8", "name": "Test8",
"type_param": "bool", "type_param": "bool",
"file": ".*gtest_list_output_unittest_.cc", "file": ".*gtest_list_output_unittest_.cc",
"line": 62 "line": 61
} }
\] \]
}, },
@ -160,13 +160,13 @@ EXPECTED_JSON = """{
"name": "Test9", "name": "Test9",
"type_param": "int", "type_param": "int",
"file": ".*gtest_list_output_unittest_.cc", "file": ".*gtest_list_output_unittest_.cc",
"line": 69 "line": 66
}, },
{ {
"name": "Test10", "name": "Test10",
"type_param": "int", "type_param": "int",
"file": ".*gtest_list_output_unittest_.cc", "file": ".*gtest_list_output_unittest_.cc",
"line": 70 "line": 67
} }
\] \]
}, },
@ -178,13 +178,13 @@ EXPECTED_JSON = """{
"name": "Test9", "name": "Test9",
"type_param": "bool", "type_param": "bool",
"file": ".*gtest_list_output_unittest_.cc", "file": ".*gtest_list_output_unittest_.cc",
"line": 69 "line": 66
}, },
{ {
"name": "Test10", "name": "Test10",
"type_param": "bool", "type_param": "bool",
"file": ".*gtest_list_output_unittest_.cc", "file": ".*gtest_list_output_unittest_.cc",
"line": 70 "line": 67
} }
\] \]
}, },

View File

@ -53,16 +53,13 @@ TEST_P(ValueParamTest, Test5) {}
TEST_P(ValueParamTest, Test6) {} TEST_P(ValueParamTest, Test6) {}
INSTANTIATE_TEST_SUITE_P(ValueParam, ValueParamTest, ::testing::Values(33, 42)); INSTANTIATE_TEST_SUITE_P(ValueParam, ValueParamTest, ::testing::Values(33, 42));
#if GTEST_HAS_TYPED_TEST
template <typename T> template <typename T>
class TypedTest : public ::testing::Test {}; class TypedTest : public ::testing::Test {};
typedef testing::Types<int, bool> TypedTestTypes; typedef testing::Types<int, bool> TypedTestTypes;
TYPED_TEST_SUITE(TypedTest, TypedTestTypes); TYPED_TEST_SUITE(TypedTest, TypedTestTypes);
TYPED_TEST(TypedTest, Test7) {} TYPED_TEST(TypedTest, Test7) {}
TYPED_TEST(TypedTest, Test8) {} TYPED_TEST(TypedTest, Test8) {}
#endif
#if GTEST_HAS_TYPED_TEST_P
template <typename T> template <typename T>
class TypeParameterizedTestSuite : public ::testing::Test {}; class TypeParameterizedTestSuite : public ::testing::Test {};
TYPED_TEST_SUITE_P(TypeParameterizedTestSuite); TYPED_TEST_SUITE_P(TypeParameterizedTestSuite);
@ -72,7 +69,6 @@ REGISTER_TYPED_TEST_SUITE_P(TypeParameterizedTestSuite, Test9, Test10);
typedef testing::Types<int, bool> TypeParameterizedTestSuiteTypes; // NOLINT typedef testing::Types<int, bool> TypeParameterizedTestSuiteTypes; // NOLINT
INSTANTIATE_TYPED_TEST_SUITE_P(Single, TypeParameterizedTestSuite, INSTANTIATE_TYPED_TEST_SUITE_P(Single, TypeParameterizedTestSuite,
TypeParameterizedTestSuiteTypes); TypeParameterizedTestSuiteTypes);
#endif
int main(int argc, char **argv) { int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);

View File

@ -3187,8 +3187,6 @@ TEST_F(DisabledTestsTest, DISABLED_TestShouldNotRun_2) {
// Tests that disabled typed tests aren't run. // Tests that disabled typed tests aren't run.
#if GTEST_HAS_TYPED_TEST
template <typename T> template <typename T>
class TypedTest : public Test { class TypedTest : public Test {
}; };
@ -3210,12 +3208,8 @@ TYPED_TEST(DISABLED_TypedTest, ShouldNotRun) {
FAIL() << "Unexpected failure: Disabled typed test should not run."; FAIL() << "Unexpected failure: Disabled typed test should not run.";
} }
#endif // GTEST_HAS_TYPED_TEST
// Tests that disabled type-parameterized tests aren't run. // Tests that disabled type-parameterized tests aren't run.
#if GTEST_HAS_TYPED_TEST_P
template <typename T> template <typename T>
class TypedTestP : public Test { class TypedTestP : public Test {
}; };
@ -3246,8 +3240,6 @@ REGISTER_TYPED_TEST_SUITE_P(DISABLED_TypedTestP, ShouldNotRun);
INSTANTIATE_TYPED_TEST_SUITE_P(My, DISABLED_TypedTestP, NumericTypes); INSTANTIATE_TYPED_TEST_SUITE_P(My, DISABLED_TypedTestP, NumericTypes);
#endif // GTEST_HAS_TYPED_TEST_P
// Tests that assertion macros evaluate their arguments exactly once. // Tests that assertion macros evaluate their arguments exactly once.
class SingleEvaluationTest : public Test { class SingleEvaluationTest : public Test {

View File

@ -163,16 +163,13 @@ TEST_P(ValueParamTest, HasValueParamAttribute) {}
TEST_P(ValueParamTest, AnotherTestThatHasValueParamAttribute) {} TEST_P(ValueParamTest, AnotherTestThatHasValueParamAttribute) {}
INSTANTIATE_TEST_SUITE_P(Single, ValueParamTest, Values(33, 42)); INSTANTIATE_TEST_SUITE_P(Single, ValueParamTest, Values(33, 42));
#if GTEST_HAS_TYPED_TEST
// Verifies that the type parameter name is output in the 'type_param' // Verifies that the type parameter name is output in the 'type_param'
// XML attribute for typed tests. // XML attribute for typed tests.
template <typename T> class TypedTest : public Test {}; template <typename T> class TypedTest : public Test {};
typedef testing::Types<int, long> TypedTestTypes; typedef testing::Types<int, long> TypedTestTypes;
TYPED_TEST_SUITE(TypedTest, TypedTestTypes); TYPED_TEST_SUITE(TypedTest, TypedTestTypes);
TYPED_TEST(TypedTest, HasTypeParamAttribute) {} TYPED_TEST(TypedTest, HasTypeParamAttribute) {}
#endif
#if GTEST_HAS_TYPED_TEST_P
// Verifies that the type parameter name is output in the 'type_param' // Verifies that the type parameter name is output in the 'type_param'
// XML attribute for type-parameterized tests. // XML attribute for type-parameterized tests.
template <typename T> template <typename T>
@ -183,7 +180,6 @@ REGISTER_TYPED_TEST_SUITE_P(TypeParameterizedTestSuite, HasTypeParamAttribute);
typedef testing::Types<int, long> TypeParameterizedTestSuiteTypes; // NOLINT typedef testing::Types<int, long> TypeParameterizedTestSuiteTypes; // NOLINT
INSTANTIATE_TYPED_TEST_SUITE_P(Single, TypeParameterizedTestSuite, INSTANTIATE_TYPED_TEST_SUITE_P(Single, TypeParameterizedTestSuite,
TypeParameterizedTestSuiteTypes); TypeParameterizedTestSuiteTypes);
#endif
int main(int argc, char** argv) { int main(int argc, char** argv) {
InitGoogleTest(&argc, argv); InitGoogleTest(&argc, argv);