Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

Improved assertion documentation

Mentioned that decomposing `&&` and `||` is not supported, gave examples
+ possible workarounds.

Closes #621, #787, #341 and maybe others I haven't found.
Commit
c97ada1910d149dc811b29073685ffc26e750cec
Author
Martin Hořeňovský ·
Parents
615aa071a8f7

Files · Download .tar.gz

Changes

 docs/assertions.md | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/docs/assertions.md b/docs/assertions.md
index 82bb96a3..f64fdcfe 100644
--- a/docs/assertions.md
+++ b/docs/assertions.md
@@ -34,6 +34,15 @@ Example:
 REQUIRE_FALSE( thisReturnsFalse() );
 ```
 
+Do note that "overly complex" expressions cannot be decomposed and thus will not compile. This is done partly for practical reasons (to keep the underlying expression template machinery to minimum) and partly for philosophical reasons (assertions should be simple and deterministic).
+
+Examples:
+* `CHECK(a == 1 && b == 2);`
+This expression is too complex because of the `&&` operator. If you want to check that 2 or more properties hold, you can either put the expression into parenthesis, which stops decomposition from working, or you need to decompose the expression into two assertions: `CHECK( a == 1 ); CHECK( b == 2);`
+* `CHECK( a == 2 || b == 1 );`
+This expression is too complex because of the `||` operator. If you want to check that one of several properties hold, you can put the expression into parenthesis (unlike with `&&`, expression decomposition into several `CHECK`s is not possible).
+
+
 ### Floating point comparisons
 
 When comparing floating point numbers - especially if at least one of them has been computed - great care must be taken to allow for rounding errors and inexact representations.