Possible Duplicate:
How can we apply a non-vararg function over a va_list?
I'm writing a unit test framework in C (see SO for more information, or view the code at GitHub). I want to generate random test cases and throw them at a function, e.g. bool is_odd(int i)
, bool a_plus_b_equals_c(int a, int b, int c)
.
If all the test cases pass, the framework will print "SUCCESS"
.
If a test case fails, I want the framework to print the offending values, and the framework can't know the types ahead of time (no hard coding).
How can I printf()
a collection of values with different, arbitrary types?
What's worse is that the functions to test may require very complex input. It's not hard to create a random AVL tree, but how can we handle printing that, or an integer, or anything else?