From 7e2cef49521523a27b114e488d163f9d20c5bb12 Mon Sep 17 00:00:00 2001 From: Dmitry-Me Date: Thu, 19 Oct 2017 19:05:16 +0300 Subject: [PATCH] Improve test coverage for %z used with printf --- test/testio.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/testio.cpp b/test/testio.cpp index 03194e11f..7c2776dc6 100644 --- a/test/testio.cpp +++ b/test/testio.cpp @@ -1995,6 +1995,12 @@ private: ASSERT_EQUALS("[test.cpp:2]: (warning) %zx in format string (no. 1) requires 'size_t' but the argument type is 'signed int'.\n" "[test.cpp:2]: (warning) %zu in format string (no. 2) requires 'size_t' but the argument type is 'long double'.\n", errout.str()); + check("void foo(int i, long double ld) {\n" + " printf(\"%tx %tu\", i, ld);\n" + "}"); + ASSERT_EQUALS("[test.cpp:2]: (warning) %tx in format string (no. 1) requires 'unsigned ptrdiff_t' but the argument type is 'signed int'.\n" + "[test.cpp:2]: (warning) %tu in format string (no. 2) requires 'unsigned ptrdiff_t' but the argument type is 'long double'.\n", errout.str()); + // False negative test check("void foo(unsigned int i) {\n" " printf(\"%h\", i);\n"