Thread (73 messages) 73 messages, 6 authors, 2024-08-02

Re: [PATCH 6/6] t-strbuf: use TEST_RUN

From: René Scharfe <hidden>
Date: 2024-07-14 11:44:22

Am 10.07.24 um 15:55 schrieb Phillip Wood:
On 02/07/2024 16:14, phillip.wood123@gmail.com wrote:
quoted
Getting rid of the untyped test arguments is definitely a benefit of this approach.
That got me thinking how we might make type-safe setup()
functions. The diff below shows how we could define a macro to
generate the functions. DEFINE_SETUP_FN(char, ch) defines setup_ch()
that takes a test function and a char that is passed to the test with
the initialized strbuf. I'm not sure that's the way we want to go for
this test file but I thought I'd post it in case it is useful for
future tests.
I'm sympathetic with the idea of enhancing the weak type system of C to
avoid mistakes.  Hiding the use of void pointers behind typed wrappers
can be useful.  Not using void pointers is even better and clearer,
though, where possible.

Thought about using such wrappers around qsort(3) and friends long ago
as well as parse_options() more recently, but didn't arrive at mergeable
patches, yet.

Initialization and destruction seem easy and familiar enough to not
warrant the use of void pointers.  No need to get fancy just for basic
necessities IMHO.

René
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help