--- Michael G Schwern <[EMAIL PROTECTED]> wrote: 
> Yucko.
> 
> Test::More implements cmp_ok() using an eval.  Could a macro prove useful
> here to do something similar?
> 
> cmp_ok(foo, 'int', '==', bar);

Good idea Schwern.
These test suites inevitably degenerate into macro crack-pipe
smoking sessions. Lacking 'eval', it is always going to be very
hard work to even get close to Perl's Test::More functionality
and ease-of-use in C.

I don't have a filthy enough mind to make your:
  cmp_ok(foo, 'int', '==', bar);
macro work (mainly because '==' is not a valid C identifier).
But I can make this one work:
  cmp_ok(foo, int, eq, bar);
pretty easily:

#include <stdio.h>
void cmp_ok_inteq(int s, int t) {
    printf("in cmp_ok_inteq: %d %d\n", s, t);
}
void cmp_ok_streq(const char* s, const char* t) {
    printf("in cmp_ok_streq: '%s' '%s'\n", s, t);
}
#define cmp_ok(s, y, o, t)  cmp_ok_##y##o(s, t)
int main() {
    int ifoo = 42;
    int ibar = 43;
    static const char* sfoo = "foo";
    static const char* sbar = "bar";
    cmp_ok(ifoo, int, eq, ibar);
    cmp_ok(sfoo, str, eq, sbar);
    return 0;
}

/-\



Find local movie times and trailers on Yahoo! Movies.
http://au.movies.yahoo.com

Reply via email to