-
Notifications
You must be signed in to change notification settings - Fork 179
Required macro as for loop (with issues fixed) #63
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
Conversation
merged. Thanks!
…he SlowTestHelper namespace. These tests are actually run by new test SlowTestsWithTimeExemptionsPass.
CHECK_EQUAL no longer crashes if string pointers are NULL. Closes #8.
…tForFixtures Fix unit test time constraint exempt for fixtures; closes #9.
…st. This best preserved the intent of the original definition while supporting a non-conformant compiler that could not handle the mismatch.
Changed all parameters to TestReporterStdout::ReportSummary to be const. Closes #15.
…ed trailing 'f' from floats and formatted all floats and doubles to '%0.6f'.
Changed sprintf to snprintf in MemoryOutStream::FormatToStream. Fixes #18.
…ded strings for each sizeof() the common integral sizes to eliminate dependency on platform-specific sizes.
…MemoryOutStream Converted integral stream testing to min/max/mid style. Fixes #14.
Unfortunately MSC does not support C99 where snprintf was added to the standard. As a workaround alias _snprint to snprintf.
Visual Studio 2010 Project Files
… tests for std::exception and non.
Rename `CheckFixture::Throw` to `CheckFixture::PerformCheckWithNonStdThrow`. Rename `CheckFixture::StdThrow` to CheckFixture::PerformCheckWithStdThrow`.
…itional tests for std:: exceptions.
…itional tests for std:: exceptions.
Add changes required to compile with MS VC6
* Add some headers to the list of installed files. * Specify the "foreign" strictness so that automake does not complain about missing files. * Specify a directory for m4 macros as suggested by libtoolize. * Add autotools-generated files to gitignore.
Integrating test failures into QTCreator IDE build errors
Fix autotools configuration
fprintf had incorrect number of arguments.
Fix crash bug in msvc
…nit test when an assert fails. The following macros have been added: REQUIRE_CHECK REQUIRE_EQUAL REQUIRE_CLOSE REQUIRE_ARRAY_EQUAL REQUIRE_ARRAY_CLOSE REQUIRE_ARRAY2D_CLOSE REQUIRE_THROW REQUIRE_ASSERT An example of when these type of checks are useful: std::vector<int> v = foo(); REQUIRE_EQUAL(3, v.size()); // test stops here on a fail // so we don't segfault looking at // v[0] below. CHECK_EQUAL(1, v[0]); CHECK_EQUAL(2, v[1]); CHECK_EQUAL(3, v[2]); When UNITTEST_NO_EXCEPTIONS is defined, the behavior of the REQUIRE_* macros falls back to match their CHECK_* counterparts. This means in the above example that we would segfault checking v[0] should v not be of size 3.
…ion is raised in REQUIRE_* macros.
test when an assert fails. The following macro has been added: REQUIRE An example of when these type of checks are useful: std::vector<int> v = foo(); REQUIRE(CHECK_EQUAL(3, v.size())); // test stops here on a fail // so we don't segfault looking at // v[0] below. CHECK_EQUAL(1, v[0]); CHECK_EQUAL(2, v[1]); CHECK_EQUAL(3, v[2]); Multiple checks are supported as follows: REQUIRE({ CHECK_EQUAL(1, 2); CHECK(true); }; In the multiple check scenario, all the checks in the REQUIRE block will be run. After which, if any failures were reported, the TEST case will be stopped. When UNITTEST_NO_EXCEPTIONS is defined, REQUIRE is a noop.
…d exception is raised in REQUIRE_* macros." This reverts commit c8522b0.
…stop a unit test" This reverts commit 856d881.
I changed the definition of the REQUIRE macro to use for loops and some comma operator shenanigans to allow things like: REQUIRE { CHECK(...); CHECK_EQUAL(..., ...); } or REQUIRE CHECK(...); I updated the tests and they all passed on my machine. My only concern is that some compilers might complain about the unreachable code in the (throw UnitTest::AssertException(), true) expression.
(1) unreachable code in for loop shenanigans is eliminated. (2) code after a failing REQUIRE check no longer executes. Used a decorating TestReporter to achive this.
@@ -22,6 +23,9 @@ class UNITTEST_LINKAGE TestResults | |||
int GetFailureCount() const; | |||
|
|||
private: | |||
friend class RequiredCheckTestReporter; |
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.
I could have avoided using friend here and introduced a getter/setter instead. I wanted to avoid signature changes to existing classes exported in shared libraries. (This is admittedly probably a silly concern, and I'm happy to change this).
This is interesting, but I'm going to hold on including it until after the long-promised and long-delayed 1.5 "release". At which point we may be able to make a "cleaner" version that doesn't require quite as much weird. |
Replaced by #95 |
I riffed on pjohnmeyer's fix for REQUIRE that used a for loop to get the desired syntax. I primarily fixed two issues:
(1) no more unreachable code in the for loop.
(2) code appearing after a failing check in a REQUIRE block will no longer execute.
I used a RAII object instantiated in the for loop declaration to install a decorated TestReporter (ThrowingTestReporter) to achieve the desired behavior and eliminate the for loop shenanigans.
My main concern now is whether we should use UnitTest::AssertException for this or use a new exception. The changes to UnitTest++/CheckMacros.h could potentially be a breaking change to any existing code using AssertException in unexpected ways.