Re: RFC: GLib testing framework
- From: "Mikkel Kamstrup Erlandsen" <mikkel kamstrup gmail com>
- To: gtk-devel-list gnome org
- Subject: Re: RFC: GLib testing framework
- Date: Wed, 7 Nov 2007 13:36:17 +0100
"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);
Any IDE supporting syntax highlighting (the real kind - with red underlining when you don't close braces or forget semi-colons etc.) will likely choke on this non-C syntax, as will many more advanced code-introspection tools.
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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]