Re: RFC: GLib testing framework



On 11/1/07, Tim Janik <timj imendio com> wrote:

I don't have much in terms of comments. My general reaction to
grandiose test frameworks is that fixtures, setup/teardown,
hierarchical test suites are too much overhead for me. Maybe this
approach to testing works for people who are move
disciplined than me, I prefer the simple-minded make check approach...

One thing I find pretty useful, that has not been mentioned so far (or
I missed it) is regression tests for bugs. For these it is very useful
to have some standardized way to refer to the bug they are testing.

> - 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)

Matthias


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