Re: RFC: GLib testing framework
- Date: Wed, 7 Nov 2007 13:36:17 +0100
- From: "Mikkel Kamstrup Erlandsen" <mikkel.kamstrup@xxxxxxxxx>
- Subject: Re: RFC: GLib testing framework
"Matthias Clasen" <matthias clasen gmail com>, Tue, 6 Nov 2007 13:12:02 -0500
> On 11/1/07, Tim Janik <timj imendio com> wrote:
> - we provide an extended set of assertions for strings, ints and floats
> that allow printing of assertion arguments upon failures to reduce
> the need for debugging:
> g_assert_cmpfloat (arg1, cmpop, arg2);
> g_assert_cmpint (arg1, cmpop, arg2);
> g_assert_cmpstr (arg1, cmpop, arg2);
> used like:
> g_assert_cmpstr ("foo", !=, "faa");
> g_assert_cmpfloat (3.3, <, epsilon);
> g_assert() is still available of course, but using the above variants,
> assertion messages can be more elaborate, e.g.:
> ** testing.c:test_assertions(): assertion failed '(3.3 < epsilon)': (3.3 < 0.5)
This syntax strikes me as not particularly elegant and a pretty severe
clash with
C syntax. I don't think I can get myself to insert random commas into
expressions like that.
How about this instead ?
g_assert_with_message ("foo not smaller than bar", foo > bar)
While I am overly exited about the possiblity of a general testing framework in glib I have problems with the current syntax:
g_assert_cmp* (arg1, cmpop, qrg2);
A toally different thing is that JUnit has method that asserts that two floats/doubles are within a specified range of each other (ie. equality testing for floats/doubles). How about:
g_assert_cmpfloat_delta (arg1, arg2, delta);
g_assert_cmpdouble_delta (arg1, arg2, delta);
Cheers,
Mikkel
_______________________________________________ gtk-devel-list mailing list gtk-devel-list@xxxxxxxxx http://mail.gnome.org/mailman/listinfo/gtk-devel-list
- Prev by Date: Re: bug test links (Re: RFC: GLib testing framework)
- Next by Date: Re: RFC: GLib testing framework
- Previous by thread: GLib 2.14.3
- Next by thread: Little documentation patch
- Index(es):