Skip to content

Commit 3089352

Browse files
committed
Improve test coverage for %lld used with printf
1 parent fe5dd55 commit 3089352

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test/testio.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2182,6 +2182,20 @@ class TestIO : public TestFixture {
21822182
"[test.cpp:6]: (warning) %lx in format string (no. 1) requires 'unsigned long' but the argument type is 'unsigned int'.\n"
21832183
"[test.cpp:7]: (warning) %llx in format string (no. 1) requires 'unsigned long long' but the argument type is 'unsigned int'.\n", errout.str());
21842184

2185+
check("void foo(int i, intmax_t im, ptrdiff_t p) {\n"
2186+
" printf(\"%lld\", i);\n"
2187+
" printf(\"%lld\", im);\n"
2188+
" printf(\"%lld\", p);\n"
2189+
"}");
2190+
ASSERT_EQUALS("[test.cpp:2]: (warning) %lld in format string (no. 1) requires 'long long' but the argument type is 'signed int'.\n", errout.str());
2191+
2192+
check("void foo(intmax_t im, ptrdiff_t p) {\n"
2193+
" printf(\"%lld\", im);\n"
2194+
" printf(\"%lld\", p);\n"
2195+
"}", false, true, Settings::Win64);
2196+
ASSERT_EQUALS("[test.cpp:2]: (portability) %lld in format string (no. 1) requires 'long long' but the argument type is 'intmax_t {aka signed long long}'.\n"
2197+
"[test.cpp:3]: (portability) %lld in format string (no. 1) requires 'long long' but the argument type is 'ptrdiff_t {aka signed long long}'.\n", errout.str());
2198+
21852199
check("class Foo {\n"
21862200
" double d;\n"
21872201
" struct Bar {\n"

0 commit comments

Comments
 (0)