In theory the EXPECT form allows you to get more test output on test failure.
In practice it makes it easy to write bugs, like this one:
FilePath dir;
EXPECT_TRUE(SetupTempDirectory(&dir));
DoWorkWith(dir);
When SetupTempDirectory failed, the test continued running with an
empty directory!
This seems to have caused a bot to commit suicide today, when
DoWorkWith decided to recursively delete the directory, thinking it
was a temporary one.
I think as a general rule, we should always use the ASSERT_ forms
unless the author of the test knows exactly the consequences of
EXPECT.
Please be cognizant of this when writing and reviewing test code. I'm
also considering cleaning up some files with a sed script.
Your general rule is good, but keep in mind that you cannot use the
ASSERT_xxx form inside functions that do not return void. Doing so
generates compiler error C2440 (in visual studio).
Thanks,
Roger
-
> --
> Chromium Developers mailing list: chromi...@chromium.org
> View archives, change email options, or unsubscribe:
> http://groups.google.com/a/chromium.org/group/chromium-dev
>
I think as a general rule, we should always use the ASSERT_ forms
unless the author of the test knows exactly the consequences of
EXPECT.
On Jul 29, 10:46 am, Peter Kasting <pkas...@google.com> wrote:Use the ASSERT form to prevent the test from crashing
> (in addition to the obvious use on tests which would
> result in a subsequent crash if failed).
MyFoo* foo = MakeFoo(testvalue);
ASSERT(NULL != foo);
EXPECT(5, foo->GimmeFive());