-
Notifications
You must be signed in to change notification settings - Fork 109
Use the do {} while (false) idiom for BOOST_TEST_THROWS() and BOOST_TEST_NO_THROW() #205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
This is technically a breaking change because the semicolon is now required, whereas it wasn't before. But it looks like all our uses have a semicolon. The backslash at the last line shouldn't be present. We should remove it from BOOST_TEST_THROWS, instead of adding it to BOOST_TEST_NO_THROW. |
I thought the convention was to terminate with a
Didn't notice this hadn't been done for |
…EST_NO_THROW() Reason: Common hygiene for multi-line macros. Makes things like if (condition) BOOST_TEST_THROWS(...); else ... work correctly. Also, it doesn't generate an empty statement (which compilers may warn about) when the user adds a semicolon (which they usually do).
459d57d
to
8a352e2
Compare
Yeah :-/ |
Sigh. Which version of MSVC? I don't get that warning with MSVC 2022 and |
Up to msvc-12.0 according to Appveyor. |
Hmm. We might try with |
Just add |
0cfc658
to
d30689c
Compare
BOOST_TEST_xxx is a public macro name. Please use BOOST_LWT_DETAIL_xxx for implementation details. |
d30689c
to
a931f06
Compare
One other alternative we could try is |
That doesn't play well with the semicolon (the one after the macro invocation). |
48268d5
to
7ffb4f8
Compare
#define BOOST_TEST_ALL_WITH(begin1, end1, begin2, end2, predicate) ( ::boost::detail::test_all_with_impl(BOOST_LIGHTWEIGHT_TEST_OSTREAM, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, begin1, end1, begin2, end2, predicate) ) | ||
|
||
|
||
#if !defined(BOOST_MSVC) || (BOOST_MSVC > 1900) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nit: better spell the second comparison as BOOST_MSVC >= x
, where x
is the oldest version we know works. This saves from some SP or Update with a version that is higher than 1900 but still issues the warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1900 looks wrong, 1900 is msvc 14.0 unpatched. Should be >= 1900.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that I test if the compiler is not MSVC or is MSVC > 2015. I think 2015 still emits the warning for do {} while (false)
(while MSVC 2017 doesn't), right? I might change the second test to >= 1910
though, as Lastique suggested.
MSVC 2015 == 1900
MSVC 2017 == 1910
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, msvc-14.0 doesn't emit the warning. But if it did, >= 1910 would be the correct check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, sorry. Too many irons in the fire :-). Fixed, now.
7ffb4f8
to
4ee817d
Compare
Everything fails, probably because you're missing a semicolon here |
|
Reason: See the new code comment.
4ee817d
to
1ed1e04
Compare
Do you prefer that? (Why?) |
It's idiomatic because that's what Nowadays |
I don't have a strong opinion about that. I can change it, if you like. (About |
Yes please, let's go with |
Reason: Common hygiene for multi-line macros. Makes things like
work correctly. Also, it doesn't generate an empty statement (which compilers may warn about) when the user adds a semicolon (which they usually do).