pekingduck / googletest

Automatically exported from code.google.com/p/googletest
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Improve SCOPED_TRACE #364

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In gtest.h you have:

#define SCOPED_TRACE(message) \
  ::testing::internal::ScopedTrace GTEST_CONCAT_TOKEN_(gtest_trace_, __LINE__)(\
    __FILE__, __LINE__, ::testing::Message() << (message))

If you get rid of parentheses around (message), you would be able to do the 
following (way cool)!

  SCOPED_TRACE("Test with a=" << my_a << ", b=" << my_b);

Original issue reported on code.google.com by igorl...@gmail.com on 30 Mar 2011 at 7:19

GoogleCodeExporter commented 9 years ago
As the issue template suggests, please send feature requests to the 
googletestframework@googlegroups.com mailing list instead.  Thanks.

We've discussed this before.  While convenient, this syntax is misleading as it 
doesn't match how the expression is parsed by C++.  People will have a hard 
time figuring out what '"Test with a=" << my_a' means given that it's not a 
valid C++ construct.

Please write

  SCOPED_TRACE(testing::Message() << "Test with a=" << my_a);

instead.

Original comment by w...@google.com on 30 Mar 2011 at 7:24