Re: RFC: GLib testing framework

On 07/11/2007, Tim Janik <timj imendio com> wrote:
On Wed, 7 Nov 2007, Morten Welinder wrote:

>> nobody has to use this syntax. you can stick to the ever simple:
>>    g_assert (foo > bar);
>> however if you want the value of 'foo' and 'bar' be printed out, instead
>> of just the value of (foo > bar) which would be 0 or 1, then there are
>> no other means than using something simialr to:
>>    g_assert_cmpfloat (foo, >, bar);
> No other way?  You just need to think outside the box^w^wcpp.  How
> about a pre-cpp filter that looks at the source code, finds the g_assert,
> and does a little creative rewriting?

how about that? bad.
we don't use a preprocessor like moc before cpp+cc. if we did,
GObject would look a million times different.
people are coding such a thing after the fact these days though,
look at vala to see how it looks like.

How about token concatenation[1]?

#define g_assert_cmp (arg1, cmp_op, arg2) \
    g_assert_cmp_##CMP_OP (arg1, arg2);

Then implement private methods:


Then call it like

g_assert_cmp (1, G_EQUALS, 2);


[1]: For the CPP challenged like me:

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]