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