On 3/10/09, Anselm R Garbe <[email protected]> wrote:
> 2009/3/10 Richard Pöttler <[email protected]>:
>> I just wanted to ask you guys if you could recommend me a tool to
>> unit test my C code. So far I only found CUnit, Check and CuTest but
>> haven't dug into any of them. Do you have any suggestions?
>
> #include <assert.h>
>

i see two immediate problems with assert:
1) one may want a message per failed test (to have a list) instead of abort
2) eg. equality checks are very common, but with assert
    assert(x == y && "important eq check")
the values of x,y are not shown in case of failure (which are
important for understanding what went wrong)

one can easily define helper macros like
print_assert(condition)
eq_assert(x, y, message)
...

i'm not sure whether it is convenient to use or not.
unfortunately there are many special cases, like the eq_assert, when
it is possible to print useful additional messages without repetitive
printfs and
most test "frameworks" exploit these situations to provide a more
complete tool, but they are difficult to use in my experience.

Reply via email to