summaryrefslogtreecommitdiffstats
path: root/googletest/test/googletest-output-test_.cc
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2018-12-20 17:54:19 (GMT)
committerMark Barolak <mbar@google.com>2018-12-20 19:09:52 (GMT)
commita83cc11abe4856a60d92ceba2d65af8236cc3500 (patch)
treea5308d55e463496592e1b624730121f46b9c3c64 /googletest/test/googletest-output-test_.cc
parent9494c45e75a55547f3f183a1161fbd39d29b994e (diff)
downloadgoogletest-a83cc11abe4856a60d92ceba2d65af8236cc3500.zip
googletest-a83cc11abe4856a60d92ceba2d65af8236cc3500.tar.gz
googletest-a83cc11abe4856a60d92ceba2d65af8236cc3500.tar.bz2
Googletest export
Add public entry point testing::RegisterTest. PiperOrigin-RevId: 226350937
Diffstat (limited to 'googletest/test/googletest-output-test_.cc')
-rw-r--r--googletest/test/googletest-output-test_.cc50
1 files changed, 50 insertions, 0 deletions
diff --git a/googletest/test/googletest-output-test_.cc b/googletest/test/googletest-output-test_.cc
index 67de2d1..f86d814 100644
--- a/googletest/test/googletest-output-test_.cc
+++ b/googletest/test/googletest-output-test_.cc
@@ -1024,6 +1024,56 @@ TEST_F(ExpectFailureTest, ExpectNonFatalFailureOnAllThreads) {
"Some other non-fatal failure.");
}
+class DynamicFixture : public testing::Test {
+ protected:
+ DynamicFixture() { printf("DynamicFixture()\n"); }
+ ~DynamicFixture() override { printf("~DynamicFixture()\n"); }
+ void SetUp() override { printf("DynamicFixture::SetUp\n"); }
+ void TearDown() override { printf("DynamicFixture::TearDown\n"); }
+
+ static void SetUpTestCase() { printf("DynamicFixture::SetUpTestCase\n"); }
+ static void TearDownTestCase() {
+ printf("DynamicFixture::TearDownTestCase\n");
+ }
+};
+
+template <bool Pass>
+class DynamicTest : public DynamicFixture {
+ public:
+ void TestBody() override { EXPECT_TRUE(Pass); }
+};
+
+auto dynamic_test = (
+ // Register two tests with the same fixture correctly.
+ testing::RegisterTest(
+ "DynamicFixture", "DynamicTestPass", nullptr, nullptr, __FILE__,
+ __LINE__, []() -> DynamicFixture* { return new DynamicTest<true>; }),
+ testing::RegisterTest(
+ "DynamicFixture", "DynamicTestFail", nullptr, nullptr, __FILE__,
+ __LINE__, []() -> DynamicFixture* { return new DynamicTest<false>; }),
+
+ // Register the same fixture with another name. That's fine.
+ testing::RegisterTest(
+ "DynamicFixtureAnotherName", "DynamicTestPass", nullptr, nullptr,
+ __FILE__, __LINE__,
+ []() -> DynamicFixture* { return new DynamicTest<true>; }),
+
+ // Register two tests with the same fixture incorrectly.
+ testing::RegisterTest(
+ "BadDynamicFixture1", "FixtureBase", nullptr, nullptr, __FILE__,
+ __LINE__, []() -> DynamicFixture* { return new DynamicTest<true>; }),
+ testing::RegisterTest(
+ "BadDynamicFixture1", "TestBase", nullptr, nullptr, __FILE__, __LINE__,
+ []() -> testing::Test* { return new DynamicTest<true>; }),
+
+ // Register two tests with the same fixture incorrectly by ommiting the
+ // return type.
+ testing::RegisterTest(
+ "BadDynamicFixture2", "FixtureBase", nullptr, nullptr, __FILE__,
+ __LINE__, []() -> DynamicFixture* { return new DynamicTest<true>; }),
+ testing::RegisterTest("BadDynamicFixture2", "Derived", nullptr, nullptr,
+ __FILE__, __LINE__,
+ []() { return new DynamicTest<true>; }));
// Two test environments for testing testing::AddGlobalTestEnvironment().