g_assert_cmpuint() should display positive, not negative values
https://docs.gtk.org/glib/func.assert_cmpuint.html documents that g_assert_cmpuint() takes unsigned integers. However, while it DOES perform the comparison in unsigned math, it is quite disconcerting that a failed comparison uses signed output:
(results shown here with glib2-devel-2.74.07-1.fc37.x86_64 from Fedora, but persist onto mainline as of at least commit de2ff264)
$ cat foo.c
#include <glib.h>
#include <stdint.h>
int main(int argc, char **argv) {
g_test_init(&argc, &argv, NULL);
g_test_set_nonfatal_assertions();
g_assert_cmpint(0x8000000000000000LL, >, INT64_MAX);
g_assert_cmpuint(0x8000000000000000ULL, <, INT64_MAX);
return 0;
}
$ gcc -o foo -I /usr/include/glib-2.0/ -I /usr/lib64/glib-2.0/include/ -l glib-2.0 -Wall foo.c
$ ./foo 2>/dev/null
# random seed: R02S286d28b7d4d622d54e161d0463a56d10
# ERROR:foo.c:6:main: assertion failed (0x8000000000000000LL > INT64_MAX): (-9223372036854775808 > 9223372036854775807)
# ERROR:foo.c:7:main: assertion failed (0x8000000000000000ULL < INT64_MAX): (-9223372036854775808 < 9223372036854775807)
Both lines are intentionally written to fail only if the correct signed/unsigned comparison is performed; but while g_assert_cmpint() shows a correct error message, g_assert_cmpuint() makes it hard for me to debug why my test failed when it shows a negative value instead of a positive (as displayed on the screen, the numerical statement is true rather than false, making it hard to see why the assertion failed).
It doesn't help that since g_assert_cmp* is taking a round-trip in and back out of 'long double' means that the output is platform-dependent on whether it loses precision (https://bugzilla.gnome.org/show_bug.cgi?id=788385 mentions that the casts are intentional to shut up the compiler, on the weak grounds that a failed assertion losing precision is not fatal to developers). I'm hoping to find time to work on a patch to handle integers separately from floating-point (no loss of precision), but wanted to at least document this in the meantime.