[prev in list] [next in list] [prev in thread] [next in thread]
List: gtk-devel
Subject: Re: RFC: GLib testing framework
From: "Mikkel Kamstrup Erlandsen" <mikkel.kamstrup () gmail ! com>
Date: 2007-11-07 20:06:00
Message-ID: 9961daf10711071206l418251ddx3cf07c5aa5c29bab () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
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:
g_assert_cmp_G_LESSTHAN
g_assert_cmp_G_EQUALS
...
Then call it like
g_assert_cmp (1, G_EQUALS, 2);
Cheers,
Mikkel
[1]: For the CPP challenged like me:
http://en.wikipedia.org/wiki/C_preprocessor
[Attachment #5 (text/html)]
On 07/11/2007, <b class="gmail_sendername">Tim Janik</b> <<a \
href="mailto:timj@imendio.com">timj@imendio.com</a>> wrote:<div><span \
class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px \
solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> On Wed, 7 \
Nov 2007, Morten Welinder wrote:<br><br>>> nobody has to use this syntax. you \
can stick to the ever simple:<br>>> g_assert (foo > \
bar);<br>>><br>>> however if you want the value of 'foo' and \
'bar' be printed out, instead <br>>> of just the value of (foo > \
bar) which would be 0 or 1, then there are<br>>> no other means than using \
something simialr to:<br>>> g_assert_cmpfloat (foo, \
>, bar);<br>><br>> No other way? You just need to think outside \
the box^w^wcpp. How <br>> about a pre-cpp filter that looks at the \
source code, finds the g_assert,<br>> and does a little creative \
rewriting?<br><br>how about that? bad.<br>we don't use a preprocessor like moc \
before cpp+cc. if we did, <br>GObject would look a million times different.<br>people \
are coding such a thing after the fact these days though,<br>look at vala to see how \
it looks like.</blockquote><div><br>How about token concatenation[1]?<br><br> #define \
g_assert_cmp (arg1, cmp_op, arg2) \<br> g_assert_cmp_##CMP_OP \
(arg1, arg2);<br><br>Then implement private \
methods:<br><br>g_assert_cmp_G_LESSTHAN<br>g_assert_cmp_G_EQUALS<br>...<br><br>Then \
call it like<br><br> g_assert_cmp (1, G_EQUALS, \
2);<br><br>Cheers,<br>Mikkel<br><br>[1]: For the CPP challenged like me: <a \
href="http://en.wikipedia.org/wiki/C_preprocessor">http://en.wikipedia.org/wiki/C_preprocessor</a><br></div></div>
_______________________________________________
gtk-devel-list mailing list
gtk-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-devel-list
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic