Makes gtest report failures in ad hoc test assertions executed before RUN_ALL_TESTS().

This commit is contained in:
zhanyong.wan
2010-06-16 22:47:13 +00:00
parent 985a30360c
commit 682c89f755
4 changed files with 21 additions and 7 deletions

View File

@@ -40,15 +40,18 @@ int main(int argc, char **argv) {
// An ad-hoc assertion outside of all tests.
//
// This serves two purposes:
// This serves three purposes:
//
// 1. It verifies that an ad-hoc assertion can be executed even if
// no test is defined.
// 2. We had a bug where the XML output won't be generated if an
// 2. It verifies that a failed ad-hoc assertion causes the test
// program to fail.
// 3. We had a bug where the XML output won't be generated if an
// assertion is executed before RUN_ALL_TESTS() is called, even
// though --gtest_output=xml is specified. This makes sure the
// bug is fixed and doesn't regress.
EXPECT_EQ(1, 1);
EXPECT_EQ(1, 2);
return RUN_ALL_TESTS();
// The above EXPECT_EQ() should cause RUN_ALL_TESTS() to return non-zero.
return RUN_ALL_TESTS() ? 0 : 1;
}