--- Michael G Schwern <[EMAIL PROTECTED]> wrote:
> Why add that extra auto-sprintf complexity?  Can't the user do the exact
> same thing with:
> 
>       ok(some_func(i), sprintf("some_func(%d)", i));

No. sprintf in C needs a buffer and you don't know how big to make it.

> > ok2() is for situations where the code to test is sufficiently 
> > self-documenting that you don't need to provide a test name.
> > 
> >     ok2(code to test); /* test name is automatically the same as the code
> */
> > 
> > E.g.,
> > 
> >     ok(1 == 1, "1 equals one"); /* PRINT: ok 1 - 1 equals 1 */
> >     ok2(1 == 2);                /* PRINT: not ok 2 - 1 == 2 */
> 
> Why the split?  You can do variable length argument lists in C.

Not with the pre-processor. And you need the pre-processor for
__LINE__ and __FILE__.

An alternative is to drop the ugly ok2() and force the test writer
to use:

      ok(1 == 2, "");

I prefer that since I want to make it hard for people to avoid giving
a test a name, er, comment.

> > Finally, there's exit_status(), which returns an int suitable for use
> > when return'ing from main(), or calling exit().  You should always do one
> > of:
> > 
> >     return exit_status();
> >     exit(exit_status());
> 
> What is this for?  <--- possible C ignorance
> 
> I hope you're not emulating Test::More's exit code == # of tests failed
> "feature" that I'm planning on getting rid of.

I tried returning the number of failed tests in the exit status in
a C++ regression test suite a while back and dropped it because:
i) you are limited to 0-255 for this exit status;
ii) you can always tell the number of failed tests by parsing stdout;
iii) it's nice to cleanly detect a program crash; if it don't
return zero, it crashed.

/-\


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Reply via email to