Closed colonelsammy closed 12 years ago
Although note that if you use a 'while' loop then you'll get loads of this on MS compiler:
warning C4127: conditional expression is constant
This patch works for me on msvc and mingw32 (based on code of 18th Feb):
diff --git a/include/internal/catch_capture.hpp b/include/internal/catch_capture.hpp index d19f4c2..7bcb49f 100644 --- a/include/internal/catch_capture.hpp +++ b/include/internal/catch_capture.hpp @@ -683,7 +683,11 @@ inline bool isTrue }
/////////////////////////////////////////////////////////////////////////////// +#if defined(_MSC_VER)
} while (0) +#endif
///////////////////////////////////////////////////////////////////////////////
Hi Mal^H^H^HColonelSammy,
I thought I'd done this ages ago. Well I added it back in. I did it slightly differently, though. To avoid the msvc warning I use Catch::isTrue( false ), which seems to provide just the right levelofindirection(.com) to convert it to a runtime condition (I use it elsewhere for the same reason).
That said I've not had a chance to test it in msvc yet (other than on my CI server that tells me it builds ok - I should probably enable warnings as errors in that project).
Hi Phil,
On 29/02/2012 08:51, Phil Nash wrote:
I thought I'd done this ages ago. Well I added it back in. I did it slightly differently, though. To avoid the msvc warning I use Catch::isTrue( false ), which seems to provide just the right levelofindirection(.com) to convert it to a runtime condition (I use it elsewhere for the same reason).
That said I've not had a chance to test it in msvc yet (other than on my CI server that tells me it builds ok - I should probably enable warnings as errors in that project). Excellent, thanks! I'll give it a try...
BTW, congrats on getting a keynote spot! Looking forward to it ;-)
regards, Malcolm
Thanks!
On 1 Mar 2012, at 06:45, Malcolm Noyes wrote:
Hi Phil,
On 29/02/2012 08:51, Phil Nash wrote:
I thought I'd done this ages ago. Well I added it back in. I did it slightly differently, though. To avoid the msvc warning I use Catch::isTrue( false ), which seems to provide just the right levelofindirection(.com) to convert it to a runtime condition (I use it elsewhere for the same reason).
That said I've not had a chance to test it in msvc yet (other than on my CI server that tells me it builds ok - I should probably enable warnings as errors in that project). Excellent, thanks! I'll give it a try...
BTW, congrats on getting a keynote spot! Looking forward to it ;-)
regards, Malcolm
Reply to this email directly or view it on GitHub: https://github.com/philsquared/Catch/issues/72#issuecomment-4253292
Example:
define CATCH_CONFIG_MAIN
include "catch.hpp"
TEST_CASE("bad if statement", "") { size_t x = 0;
}
You need to do something like putting a do{ } while(0) around the macro body of INTERNAL_CATCH_TEST....e.g:
define INTERNAL_CATCH_TEST( expr, isNot, stopOnFailure, macroName ) \