<feed xmlns='http://www.w3.org/2005/Atom'>
<title>catch3/src/catch2/internal/catch_test_macro_impl.hpp, branch v3.4.0</title>
<subtitle>Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.</subtitle>
<link rel='alternate' type='text/html' href='https://git.progmasoft.com/catch3/'/>
<entry>
<title>Suppress -Wunused-result warning in gcc</title>
<updated>2023-05-23T21:31:55+00:00</updated>
<author>
<name>Cristian Morales Vega</name>
</author>
<published>2023-05-22T08:45:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.progmasoft.com/catch3/commit/?id=535205e2ac0d26d03126d93327b15c79ac35d3ef'/>
<id>535205e2ac0d26d03126d93327b15c79ac35d3ef</id>
<content type='text'>
See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425.
</pre>
</div>
</content>
</entry>
<entry>
<title>Move CATCH_INTERNAL_STRINGIFY macro into its own header</title>
<updated>2023-05-07T18:58:54+00:00</updated>
<author>
<name>Martin Hořeňovský</name>
</author>
<published>2023-05-07T10:09:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.progmasoft.com/catch3/commit/?id=0dc82e08dfec25faf6c6c145f3592984db7276cc'/>
<id>0dc82e08dfec25faf6c6c145f3592984db7276cc</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Use StringRef UDL for more string literals when expanding macros</title>
<updated>2023-02-20T13:31:26+00:00</updated>
<author>
<name>Martin Hořeňovský</name>
</author>
<published>2023-02-19T18:45:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.progmasoft.com/catch3/commit/?id=dcc9fa3f38f1962ef01bb4b273f999df9d0b2b3d'/>
<id>dcc9fa3f38f1962ef01bb4b273f999df9d0b2b3d</id>
<content type='text'>
* for the name of the listener when registering listener
* for the original expression in assertion macros
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* for the name of the listener when registering listener
* for the original expression in assertion macros
</pre>
</div>
</content>
</entry>
<entry>
<title>Remove unused StringRef argument from MatchExpr</title>
<updated>2022-11-10T14:25:51+00:00</updated>
<author>
<name>Martin Hořeňovský</name>
</author>
<published>2022-11-10T11:43:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.progmasoft.com/catch3/commit/?id=6e77e16ea83b928ff7a1e251df2fe8eab38963a9'/>
<id>6e77e16ea83b928ff7a1e251df2fe8eab38963a9</id>
<content type='text'>
Apart from cleaning up the code, this change also improves the
compilation time of `UsageTests/Matchers.tests.cpp` by about 2%.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Apart from cleaning up the code, this change also improves the
compilation time of `UsageTests/Matchers.tests.cpp` by about 2%.
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix references to license file</title>
<updated>2022-10-28T09:30:15+00:00</updated>
<author>
<name>Lars Toenning</name>
</author>
<published>2022-10-28T09:22:53+00:00</published>
<link rel='alternate' type='text/html' href='https://git.progmasoft.com/catch3/commit/?id=f1084fb30990fe40c8f5b70034970c7eb4e1da72'/>
<id>f1084fb30990fe40c8f5b70034970c7eb4e1da72</id>
<content type='text'>
The license file was renamed with 6a502cc2f5fedd59b3495b58708f0d6d987ed9e1
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The license file was renamed with 6a502cc2f5fedd59b3495b58708f0d6d987ed9e1
</pre>
</div>
</content>
</entry>
<entry>
<title>Suppress -Wuseless-cast Warning</title>
<updated>2022-09-22T19:00:05+00:00</updated>
<author>
<name>Björn Schäpers</name>
</author>
<published>2022-09-14T08:25:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.progmasoft.com/catch3/commit/?id=0de60d8e7ead1ddd5ba8c46b901c122eac20bf94'/>
<id>0de60d8e7ead1ddd5ba8c46b901c122eac20bf94</id>
<content type='text'>
Fixes #2520.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Fixes #2520.
</pre>
</div>
</content>
</entry>
<entry>
<title>Leak full Wparentheses suppression for GCC 9</title>
<updated>2022-05-31T21:57:09+00:00</updated>
<author>
<name>Martin Hořeňovský</name>
</author>
<published>2022-05-31T21:57:02+00:00</published>
<link rel='alternate' type='text/html' href='https://git.progmasoft.com/catch3/commit/?id=cca59235023fa30339086be845d9cd7214ecff91'/>
<id>cca59235023fa30339086be845d9cd7214ecff91</id>
<content type='text'>
Reported as an issue on Discord. I thought that by GCC 9, the
C++ frontend was fixed enough to support `_Pragma`-based
suppression correctly, but apparently I was wrong.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Reported as an issue on Discord. I thought that by GCC 9, the
C++ frontend was fixed enough to support `_Pragma`-based
suppression correctly, but apparently I was wrong.
</pre>
</div>
</content>
</entry>
<entry>
<title>Add some missing configuration includes</title>
<updated>2022-02-20T18:32:25+00:00</updated>
<author>
<name>Martin Hořeňovský</name>
</author>
<published>2022-02-19T20:27:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.progmasoft.com/catch3/commit/?id=4396a9119fa32abf966f189c6f6d9c54698d89c8'/>
<id>4396a9119fa32abf966f189c6f6d9c54698d89c8</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Disable false positive from clang-tidy</title>
<updated>2021-10-21T20:45:19+00:00</updated>
<author>
<name>Anders Schau Knatten</name>
</author>
<published>2021-09-29T13:34:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.progmasoft.com/catch3/commit/?id=22750cde0e0d2c02ab447e2500422f2711356053'/>
<id>22750cde0e0d2c02ab447e2500422f2711356053</id>
<content type='text'>
Clang-tidy is smart enough to understand that the conditional is never
updated in the loop body. It will let you get away with it if it can
prove that the conditional is always false, but that is not always
possible.

Here is an example where it's not able to prove it, and thus gives a
false positive. This is a minimal reproduction of an actual case I hit
in production, where `function` is picking the function based on some
`constexpr` logic related to which type argument is currently being
tested.

```
int f();

TEMPLATE_TEST_CASE("reproduction", "", int) {
    const auto function = []() {
        return f;
    }();
    const int error = function();
    REQUIRE(error == 0); // clang-tidy complains: bugprone-infinite-loop
}
```

I did not choose to add this test to the test suite, since we're not
running `clang-tidy` in CI afaik. To run it manually, simply add the
snippet above somewhere and run clang-tidy with
`--checks=bugprone-infinite-loop`. Or see an example at
https://godbolt.org/z/4v8b8WexP.

The reason we get the infinite loop warning in the first place is the
conditional at the end of this `do`-loop. Ideally, this conditional
would just be `while(false)`, but the actual content of the
`REQUIRE`-statement has been included here too in order to not loose
warnings from signed/unsigned comparisons. In short, if you do
`REQUIRE(i &lt; j)`, where `i` is a negative signed integer and `j` is an
unsigned integer, you're supposed to get a warning from
`-Wsign-compare`. Due to the decomposition in Catch2, you lose this
warning, which is why the content of the `REQUIRE` statement has been
added to the conditional to force the compiler to evaluate the actual
comparison as well.

This was discussed on Discord today, and an alternative approach (which
I don't have time to implement) would be to in the decomposition replace
the comparison operators with `cmp_less` and friends. These are C++20
though, and would have to be implemented manually. I am also not sure
it's a good idea to "magically" change the semantics of `&lt;` when it's
used inside a `REQUIRE` macro.

Another alternative approach would be to trigger this warning in a
different way, by including the content of the `REQUIRE` macro in a
different way which doesn't affect the for loop. But I don't have enough
of an overview here to know where would be a good place and how to test
that I didn't break anything.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Clang-tidy is smart enough to understand that the conditional is never
updated in the loop body. It will let you get away with it if it can
prove that the conditional is always false, but that is not always
possible.

Here is an example where it's not able to prove it, and thus gives a
false positive. This is a minimal reproduction of an actual case I hit
in production, where `function` is picking the function based on some
`constexpr` logic related to which type argument is currently being
tested.

```
int f();

TEMPLATE_TEST_CASE("reproduction", "", int) {
    const auto function = []() {
        return f;
    }();
    const int error = function();
    REQUIRE(error == 0); // clang-tidy complains: bugprone-infinite-loop
}
```

I did not choose to add this test to the test suite, since we're not
running `clang-tidy` in CI afaik. To run it manually, simply add the
snippet above somewhere and run clang-tidy with
`--checks=bugprone-infinite-loop`. Or see an example at
https://godbolt.org/z/4v8b8WexP.

The reason we get the infinite loop warning in the first place is the
conditional at the end of this `do`-loop. Ideally, this conditional
would just be `while(false)`, but the actual content of the
`REQUIRE`-statement has been included here too in order to not loose
warnings from signed/unsigned comparisons. In short, if you do
`REQUIRE(i &lt; j)`, where `i` is a negative signed integer and `j` is an
unsigned integer, you're supposed to get a warning from
`-Wsign-compare`. Due to the decomposition in Catch2, you lose this
warning, which is why the content of the `REQUIRE` statement has been
added to the conditional to force the compiler to evaluate the actual
comparison as well.

This was discussed on Discord today, and an alternative approach (which
I don't have time to implement) would be to in the decomposition replace
the comparison operators with `cmp_less` and friends. These are C++20
though, and would have to be implemented manually. I am also not sure
it's a good idea to "magically" change the semantics of `&lt;` when it's
used inside a `REQUIRE` macro.

Another alternative approach would be to trigger this warning in a
different way, by including the content of the `REQUIRE` macro in a
different way which doesn't affect the for loop. But I don't have enough
of an overview here to know where would be a good place and how to test
that I didn't break anything.
</pre>
</div>
</content>
</entry>
<entry>
<title>Bring back useful comment</title>
<updated>2021-09-29T16:19:31+00:00</updated>
<author>
<name>Anders Schau Knatten</name>
</author>
<published>2021-09-29T11:54:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.progmasoft.com/catch3/commit/?id=eb452e9b356de09bdb96273c035c40a8f4cb2ad3'/>
<id>eb452e9b356de09bdb96273c035c40a8f4cb2ad3</id>
<content type='text'>
In b7b346c3e56030 this conditional was simplified to just
`while( false)` rather than the current one. Then in 3a33315ff8e04, that
change was reverted. I found it hard to understand this
complicated conditional, but after some digging in history I found this
comment which used to be here. It was removed in b7b346c3e56030, but not
restored together with the revert in 3a33315ff8e04. Let's revive it.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In b7b346c3e56030 this conditional was simplified to just
`while( false)` rather than the current one. Then in 3a33315ff8e04, that
change was reverted. I found it hard to understand this
complicated conditional, but after some digging in history I found this
comment which used to be here. It was removed in b7b346c3e56030, but not
restored together with the revert in 3a33315ff8e04. Let's revive it.
</pre>
</div>
</content>
</entry>
</feed>
