--
---
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/d/optout.
--
Thanks, Gregor.It was a conscious decision for ASSERT_TRUE/EXPECT_TRUE to not provide a Boolean context, as we feel thatASSERT_TRUE(some_non_bool_expression);can be misleading/confusing. Instead ofASSERT_TRUE(some_int);EXPECT_TRUE(some_pointer);it's more intent-revealing to writeASSERT_NE(some_int, 0);
EXPECT_TRUE(some_pointer != nullptr);
On Tue, Feb 2, 2016 at 12:31 PM, 'Zhanyong Wan (λx.x x)' via Google C++ Testing Framework <googletes...@googlegroups.com> wrote:Thanks, Gregor.It was a conscious decision for ASSERT_TRUE/EXPECT_TRUE to not provide a Boolean context, as we feel thatASSERT_TRUE(some_non_bool_expression);can be misleading/confusing. Instead ofASSERT_TRUE(some_int);EXPECT_TRUE(some_pointer);it's more intent-revealing to writeASSERT_NE(some_int, 0);Requires an exemplar 'false' value.
EXPECT_TRUE(some_pointer != nullptr);That doesn't print some_pointer.
I think it's still up to the user here. We have a lot of new bool-convertible types now and soon, like std::experimental::optional, std::function, and fancy smartpointers.
I realize this thread is very old, but I just wanted to say that I don't really agree with the reasoning for not applying a boolean context in this case. For one, the language is C++, and as such I think it's reasonable to expect the same semantics inside:
afaik, this is already the case for some time now.EXPECT_TRUE et al will accept anything that converts to bool implicitly or explicitly.Is this still failing for you with a recent version of gTest?