0

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?

Community
  • 1
  • 1
mcandre
  • 22,868
  • 20
  • 88
  • 147
  • 1
    Didn't you just ask this (as part of another question)? http://stackoverflow.com/questions/7522954/how-can-we-apply-a-non-vararg-function-over-a-va-list Voting to close as a duplicate; clean up one question and make it useful, don't ask the same thing twice in 40 minutes (especially when people are providing answers on the first one). – ssube Sep 23 '11 at 00:58
  • I felt it was worth posting as a separate issue (see the new links in each post). – mcandre Sep 23 '11 at 01:00
  • The framework will just have to require users to provide print functions, e.g. `for_all(some_func, gen1, print1, gen2, print2, ...);` – mcandre Sep 23 '11 at 01:06

0 Answers0