Re: [googletest] Please fix the ASSERT* macros properly instead of breaking existing legacy code base

179 views
Skip to first unread message

Keith Ray

unread,
May 20, 2013, 1:17:00 PM5/20/13
to Szalai Endre, googletes...@googlegroups.com
ASSERT_* macros in gTests have always done a "return" if the assertion was false, and thus required the functions in which they are used to be a void function. You may be thinking of another framework where failing assertions throw an exception.


On 2013 May 20, at 5:46 AM, Szalai Endre <mcha...@gmail.com> wrote:

I was surprised to see that the latest gtest releases broke the behavior of the ASSERT_ macros. Now they support streams, but do not support usage of them inside non-void functions. This breaks so many tests and make usage of these macros very painful. I mean very. Changing method signatures are not an option, when it comes to a unittest tool. The only option now I have is to use EXPECT_ macros, which defeats the purpose of the asserts completely. Now I have to manually check if the condition was true or not and interrupt execution manually. This should be handled by the ASSERT_ macros.

Would it be an option to add a new set of ASSERT macros that do not support streaming, but do support non-void functions? That way one could have the best from the two worlds without breaking existing cases.


--
 
---
You received this message because you are subscribed to the Google Groups "Google C++ Testing Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to googletestframe...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

srz_zumix

unread,
Jun 24, 2013, 9:59:31 AM6/24/13
to googletes...@googlegroups.com
PATCH: use in a non-void function of ASSERT_ * macro.

Usage:
int f() {
  ASSERT_TRUE(false) << ::testing::AssertionReturn(1);
  return 0;
assertion_return.diff
Reply all
Reply to author
Forward
0 new messages