Re: [PATCH v2 2/6] unit-tests: add for_test
- From
René Scharfe <l.s.r@web.de>
- Date
- Jul 23, 2024, 13:58 UTC
- Message-ID
- <4ccfab92-e66c-40d4-be56-e3eb04374670@web.de>
- In-Reply-To
- <55857c83-2181-4dcb-b354-f9f7e77cd6b9@gmail.com>
Am 23.07.24 um 15:23 schrieb Phillip Wood:
Show 6 quoted lines
> On 23/07/2024 13:37, René Scharfe wrote: >> >> In which ways can for_test break? > > Using a "break" statement to exit the test early will exit the loop > without calling test__run_end()
Good point! That will only be caught at runtime by the asserts at the start of test__run_begin() or test_done() depending on whether it was the last test:
Assertion failed: (!ctx.running), function test_done, file test-lib.c, line 128.
Assertion failed: (!ctx.running), function test__run_begin, file test-lib.c, line 172.
These messages could be more helpful. And the use of the unsupported break with a first-class for-like keyword would yield a compiler error. But at least it won't go unnoticed even with this limited look-alike. Deserves a comment in test-lib.h.
René