"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "googletest/test/googletest-output-test_.cc" between
googletest-release-1.10.0.tar.gz and googletest-release-1.11.0.tar.gz

About: GoogleTest is Google's (unit) testing and mocking framework for C++ tests.

googletest-output-test_.cc  (googletest-release-1.10.0):googletest-output-test_.cc  (googletest-release-1.11.0)
skipping to change at line 479 skipping to change at line 479
} }
TEST(AddFailureAtTest, MessageContainsSpecifiedFileAndLineNumber) { TEST(AddFailureAtTest, MessageContainsSpecifiedFileAndLineNumber) {
ADD_FAILURE_AT("foo.cc", 42) << "Expected nonfatal failure in foo.cc"; ADD_FAILURE_AT("foo.cc", 42) << "Expected nonfatal failure in foo.cc";
} }
TEST(GtestFailAtTest, MessageContainsSpecifiedFileAndLineNumber) { TEST(GtestFailAtTest, MessageContainsSpecifiedFileAndLineNumber) {
GTEST_FAIL_AT("foo.cc", 42) << "Expected fatal failure in foo.cc"; GTEST_FAIL_AT("foo.cc", 42) << "Expected fatal failure in foo.cc";
} }
#if GTEST_IS_THREADSAFE
// A unary function that may die.
void DieIf(bool should_die) {
GTEST_CHECK_(!should_die) << " - death inside DieIf().";
}
// Tests running death tests in a multi-threaded context.
// Used for coordination between the main and the spawn thread.
struct SpawnThreadNotifications {
SpawnThreadNotifications() {}
Notification spawn_thread_started;
Notification spawn_thread_ok_to_terminate;
private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(SpawnThreadNotifications);
};
// The function to be executed in the thread spawn by the
// MultipleThreads test (below).
static void ThreadRoutine(SpawnThreadNotifications* notifications) {
// Signals the main thread that this thread has started.
notifications->spawn_thread_started.Notify();
// Waits for permission to finish from the main thread.
notifications->spawn_thread_ok_to_terminate.WaitForNotification();
}
// This is a death-test test, but it's not named with a DeathTest
// suffix. It starts threads which might interfere with later
// death tests, so it must run after all other death tests.
class DeathTestAndMultiThreadsTest : public testing::Test {
protected:
// Starts a thread and waits for it to begin.
void SetUp() override {
thread_.reset(new ThreadWithParam<SpawnThreadNotifications*>(
&ThreadRoutine, &notifications_, nullptr));
notifications_.spawn_thread_started.WaitForNotification();
}
// Tells the thread to finish, and reaps it.
// Depending on the version of the thread library in use,
// a manager thread might still be left running that will interfere
// with later death tests. This is unfortunate, but this class
// cleans up after itself as best it can.
void TearDown() override {
notifications_.spawn_thread_ok_to_terminate.Notify();
}
private:
SpawnThreadNotifications notifications_;
std::unique_ptr<ThreadWithParam<SpawnThreadNotifications*> > thread_;
};
#endif // GTEST_IS_THREADSAFE
// The MixedUpTestSuiteTest test case verifies that Google Test will fail a // The MixedUpTestSuiteTest test case verifies that Google Test will fail a
// test if it uses a different fixture class than what other tests in // test if it uses a different fixture class than what other tests in
// the same test case use. It deliberately contains two fixture // the same test case use. It deliberately contains two fixture
// classes with the same name but defined in different namespaces. // classes with the same name but defined in different namespaces.
// The MixedUpTestSuiteWithSameTestNameTest test case verifies that // The MixedUpTestSuiteWithSameTestNameTest test case verifies that
// when the user defines two tests with the same test case name AND // when the user defines two tests with the same test case name AND
// same test name (but in different namespaces), the second test will // same test name (but in different namespaces), the second test will
// fail. // fail.
skipping to change at line 793 skipping to change at line 736
TEST_P(ParamTest, Failure) { TEST_P(ParamTest, Failure) {
EXPECT_EQ("b", GetParam()) << "Expected failure"; EXPECT_EQ("b", GetParam()) << "Expected failure";
} }
INSTANTIATE_TEST_SUITE_P(PrintingStrings, INSTANTIATE_TEST_SUITE_P(PrintingStrings,
ParamTest, ParamTest,
testing::Values(std::string("a")), testing::Values(std::string("a")),
ParamNameFunc); ParamNameFunc);
// This #ifdef block tests the output of typed tests. // The case where a suite has INSTANTIATE_TEST_SUITE_P but not TEST_P.
#if GTEST_HAS_TYPED_TEST using NoTests = ParamTest;
INSTANTIATE_TEST_SUITE_P(ThisIsOdd, NoTests, ::testing::Values("Hello"));
// fails under kErrorOnUninstantiatedParameterizedTest=true
class DetectNotInstantiatedTest : public testing::TestWithParam<int> {};
TEST_P(DetectNotInstantiatedTest, Used) { }
// This would make the test failure from the above go away.
// INSTANTIATE_TEST_SUITE_P(Fix, DetectNotInstantiatedTest, testing::Values(1));
template <typename T> template <typename T>
class TypedTest : public testing::Test { class TypedTest : public testing::Test {
}; };
TYPED_TEST_SUITE(TypedTest, testing::Types<int>); TYPED_TEST_SUITE(TypedTest, testing::Types<int>);
TYPED_TEST(TypedTest, Success) { TYPED_TEST(TypedTest, Success) {
EXPECT_EQ(0, TypeParam()); EXPECT_EQ(0, TypeParam());
} }
skipping to change at line 832 skipping to change at line 783
return std::string("int") + ::testing::PrintToString(i); return std::string("int") + ::testing::PrintToString(i);
} }
}; };
TYPED_TEST_SUITE(TypedTestWithNames, TypesForTestWithNames, TypedTestNames); TYPED_TEST_SUITE(TypedTestWithNames, TypesForTestWithNames, TypedTestNames);
TYPED_TEST(TypedTestWithNames, Success) {} 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 {
}; };
TYPED_TEST_SUITE_P(TypedTestP); TYPED_TEST_SUITE_P(TypedTestP);
TYPED_TEST_P(TypedTestP, Success) { TYPED_TEST_P(TypedTestP, Success) {
EXPECT_EQ(0U, TypeParam()); EXPECT_EQ(0U, TypeParam());
} }
skipping to change at line 872 skipping to change at line 818
} }
if (std::is_same<T, unsigned int>::value) { if (std::is_same<T, unsigned int>::value) {
return std::string("unsignedInt") + ::testing::PrintToString(i); return std::string("unsignedInt") + ::testing::PrintToString(i);
} }
} }
}; };
INSTANTIATE_TYPED_TEST_SUITE_P(UnsignedCustomName, TypedTestP, UnsignedTypes, INSTANTIATE_TYPED_TEST_SUITE_P(UnsignedCustomName, TypedTestP, UnsignedTypes,
TypedTestPNames); TypedTestPNames);
#endif // GTEST_HAS_TYPED_TEST_P template <typename T>
class DetectNotInstantiatedTypesTest : public testing::Test {};
TYPED_TEST_SUITE_P(DetectNotInstantiatedTypesTest);
TYPED_TEST_P(DetectNotInstantiatedTypesTest, Used) {
TypeParam instantiate;
(void)instantiate;
}
REGISTER_TYPED_TEST_SUITE_P(DetectNotInstantiatedTypesTest, Used);
// kErrorOnUninstantiatedTypeParameterizedTest=true would make the above fail.
// Adding the following would make that test failure go away.
//
// typedef ::testing::Types<char, int, unsigned int> MyTypes;
// INSTANTIATE_TYPED_TEST_SUITE_P(All, DetectNotInstantiatedTypesTest, MyTypes);
#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
// name ends with DeathTest are run first. // name ends with DeathTest are run first.
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.
template <typename T> template <typename T>
class ATypedDeathTest : public testing::Test { class ATypedDeathTest : public testing::Test {
}; };
typedef testing::Types<int, double> NumericTypes; typedef testing::Types<int, double> NumericTypes;
TYPED_TEST_SUITE(ATypedDeathTest, NumericTypes); 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.
template <typename T> template <typename T>
class ATypeParamDeathTest : public testing::Test { class ATypeParamDeathTest : public testing::Test {
}; };
TYPED_TEST_SUITE_P(ATypeParamDeathTest); TYPED_TEST_SUITE_P(ATypeParamDeathTest);
TYPED_TEST_P(ATypeParamDeathTest, ShouldRunFirst) { TYPED_TEST_P(ATypeParamDeathTest, ShouldRunFirst) {
} }
REGISTER_TYPED_TEST_SUITE_P(ATypeParamDeathTest, ShouldRunFirst); 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
// EXPECT_{,NON}FATAL_FAILURE{,_ON_ALL_THREADS}. // EXPECT_{,NON}FATAL_FAILURE{,_ON_ALL_THREADS}.
class ExpectFailureTest : public testing::Test { class ExpectFailureTest : public testing::Test {
public: // Must be public and not protected due to a bug in g++ 3.4.2. public: // Must be public and not protected due to a bug in g++ 3.4.2.
enum FailureMode { enum FailureMode {
FATAL_FAILURE, FATAL_FAILURE,
NONFATAL_FAILURE NONFATAL_FAILURE
}; };
skipping to change at line 1080 skipping to change at line 1031
[]() -> DynamicFixture* { return new DynamicTest<true>; }), []() -> DynamicFixture* { return new DynamicTest<true>; }),
// Register two tests with the same fixture incorrectly. // Register two tests with the same fixture incorrectly.
testing::RegisterTest( testing::RegisterTest(
"BadDynamicFixture1", "FixtureBase", nullptr, nullptr, __FILE__, "BadDynamicFixture1", "FixtureBase", nullptr, nullptr, __FILE__,
__LINE__, []() -> DynamicFixture* { return new DynamicTest<true>; }), __LINE__, []() -> DynamicFixture* { return new DynamicTest<true>; }),
testing::RegisterTest( testing::RegisterTest(
"BadDynamicFixture1", "TestBase", nullptr, nullptr, __FILE__, __LINE__, "BadDynamicFixture1", "TestBase", nullptr, nullptr, __FILE__, __LINE__,
[]() -> testing::Test* { return new DynamicTest<true>; }), []() -> testing::Test* { return new DynamicTest<true>; }),
// Register two tests with the same fixture incorrectly by ommiting the // Register two tests with the same fixture incorrectly by omitting the
// return type. // return type.
testing::RegisterTest( testing::RegisterTest(
"BadDynamicFixture2", "FixtureBase", nullptr, nullptr, __FILE__, "BadDynamicFixture2", "FixtureBase", nullptr, nullptr, __FILE__,
__LINE__, []() -> DynamicFixture* { return new DynamicTest<true>; }), __LINE__, []() -> DynamicFixture* { return new DynamicTest<true>; }),
testing::RegisterTest("BadDynamicFixture2", "Derived", nullptr, nullptr, testing::RegisterTest("BadDynamicFixture2", "Derived", nullptr, nullptr,
__FILE__, __LINE__, __FILE__, __LINE__,
[]() { return new DynamicTest<true>; })); []() { return new DynamicTest<true>; }));
// Two test environments for testing testing::AddGlobalTestEnvironment(). // Two test environments for testing testing::AddGlobalTestEnvironment().
 End of changes. 8 change blocks. 
74 lines changed or deleted 25 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)