Refactor unit test asserts so they log context
In #30721 (moved), I created some complex macros to preserve line numbers when the unit tests fail.
We could refactor these macros into functions, if the tiny test assertions supported context.
catalyst suggests allowing file and line numbers (and functions?):
I think I see that the problem is buried in the
tinytest_macros.h. I think it's possible to work around it, but it might be nontrivial. (Rough sketch: redefine
TT_DECLARE()in helper functions to read file and line info from function parameters, and make file and line numbers explicit parameters to helper functions.)
I suggest allowing a format string, which could also print the data that we're testing. (For the tor_addr_port_lookup() tests, the best context is the address string.)