diff --git a/cfg/gtk.cfg b/cfg/gtk.cfg index 3aee2e2b1a2..e7119755b3e 100644 --- a/cfg/gtk.cfg +++ b/cfg/gtk.cfg @@ -3285,8 +3285,7 @@ - - + @@ -3299,7 +3298,7 @@ - + diff --git a/test/cfg/gtk.c b/test/cfg/gtk.c index b923135e2d9..015aa6a6a3d 100644 --- a/test/cfg/gtk.c +++ b/test/cfg/gtk.c @@ -655,3 +655,35 @@ int g_return_val_if_reached_test(const char *s) { return 0; } + +void g_ascii_formatd_test(double d) +{ + // g_ascii_formatd() writes the buffer and formats exactly one double + gchar buf[39]; + g_ascii_formatd(buf, sizeof(buf), "%.2f", d); + g_print("%s", buf); + + // cppcheck-suppress invalidPrintfArgType_sint + g_ascii_formatd(buf, sizeof(buf), "%d", d); + g_print("%s", buf); + + gchar small[4]; + // cppcheck-suppress bufferAccessOutOfBounds + g_ascii_formatd(small, sizeof(buf), "%.2f", d); + g_print("%s", small); +} + +void g_ascii_formatd_format_test(const gchar *format, int i) +{ + gchar buf[39]; + // cppcheck-suppress invalidFunctionArgBool + g_ascii_formatd(buf, sizeof(buf), format, i == 1); + g_print("%s", buf); + + struct { + double x; + } s; + // cppcheck-suppress [uninitvar, uninitStructMember] + g_ascii_formatd(buf, sizeof(buf), format, s.x); + g_print("%s", buf); +}