You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: test/testio.cpp
+30Lines changed: 30 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -972,6 +972,11 @@ class TestIO : public TestFixture {
972
972
ASSERT_EQUALS("[test.cpp:2]: (warning) %u in format string (no. 1) requires 'unsigned int *' but the argument type is 'const char *'.\n"
973
973
"[test.cpp:3]: (warning) %u in format string (no. 1) requires 'unsigned int *' but the argument type is 'const wchar_t *'.\n", errout.str());
974
974
975
+
check("void foo(long l) {\n"
976
+
" scanf(\"%u\", l);\n"
977
+
"}", true);
978
+
ASSERT_EQUALS("[test.cpp:2]: (warning) %u in format string (no. 1) requires 'unsigned int *' but the argument type is 'signed long'.\n", errout.str());
@@ -1527,6 +1542,11 @@ class TestIO : public TestFixture {
1527
1542
ASSERT_EQUALS("[test.cpp:2]: (warning) %x in format string (no. 1) requires 'unsigned int *' but the argument type is 'const char *'.\n"
1528
1543
"[test.cpp:3]: (warning) %x in format string (no. 1) requires 'unsigned int *' but the argument type is 'const wchar_t *'.\n", errout.str());
1529
1544
1545
+
check("void foo(long l) {\n"
1546
+
" scanf(\"%x\", l);\n"
1547
+
"}", true);
1548
+
ASSERT_EQUALS("[test.cpp:2]: (warning) %x in format string (no. 1) requires 'unsigned int *' but the argument type is 'signed long'.\n", errout.str());
1549
+
1530
1550
TEST_SCANF_WARN("%f", "float", "bool");
1531
1551
TEST_SCANF_WARN("%f", "float", "char");
1532
1552
TEST_SCANF_WARN("%f", "float", "signed char");
@@ -1561,6 +1581,11 @@ class TestIO : public TestFixture {
1561
1581
ASSERT_EQUALS("[test.cpp:2]: (warning) %f in format string (no. 1) requires 'float *' but the argument type is 'const char *'.\n"
1562
1582
"[test.cpp:3]: (warning) %f in format string (no. 1) requires 'float *' but the argument type is 'const wchar_t *'.\n", errout.str());
1563
1583
1584
+
check("void foo(float f) {\n"
1585
+
" scanf(\"%f\", f);\n"
1586
+
"}", true);
1587
+
ASSERT_EQUALS("[test.cpp:2]: (warning) %f in format string (no. 1) requires 'float *' but the argument type is 'float'.\n", errout.str());
1588
+
1564
1589
TEST_SCANF_WARN("%lf", "double", "bool");
1565
1590
TEST_SCANF_WARN("%lf", "double", "char");
1566
1591
TEST_SCANF_WARN("%lf", "double", "signed char");
@@ -1649,6 +1674,11 @@ class TestIO : public TestFixture {
1649
1674
ASSERT_EQUALS("[test.cpp:2]: (warning) %n in format string (no. 1) requires 'int *' but the argument type is 'const char *'.\n"
1650
1675
"[test.cpp:3]: (warning) %n in format string (no. 1) requires 'int *' but the argument type is 'const wchar_t *'.\n", errout.str());
1651
1676
1677
+
check("void foo(long l) {\n"
1678
+
" scanf(\"%n\", l);\n"
1679
+
"}", true);
1680
+
ASSERT_EQUALS("[test.cpp:2]: (warning) %n in format string (no. 1) requires 'int *' but the argument type is 'signed long'.\n", errout.str());
0 commit comments