Here's the sample code:
#include <gtest/gtest.h>
void foo() {
FAIL() << "Test";
}
TEST(DeathTest, FailTest) {
ASSERT_DEATH(foo(), "");
}
It works ok on Linux and Mac, but fails on Windows.
After a bit of debugging I think this is because "exit(1") is not called inside
"UnitTest::AddTestPartResult"
(gtest/src/gtest.cc).
This test passes if I set "::testing::FLAGS_gtest_throw_on_failure = true;"
I faced this issue in Chromium since its ~LogMessage with type=FATAL calls
FAIL().
As a result, we can't write cross-platform death tests for Chromium without the
hack described above.
Original issue reported on code.google.com by timurrrr@chromium.org on 7 Dec 2009 at 10:42
Original issue reported on code.google.com by
timurrrr@chromium.org
on 7 Dec 2009 at 10:42