Improve test coverage for wide string literals passed into printf
This commit is contained in:
parent
91202c47e6
commit
d170b496ba
|
@ -1480,6 +1480,11 @@ private:
|
|||
"[test.cpp:6]: (warning) %n in format string (no. 1) requires 'int *' but the argument type is 'std::string'.\n"
|
||||
"[test.cpp:7]: (warning) %n in format string (no. 1) requires 'int *' but the argument type is 'const char *'.\n", errout.str());
|
||||
|
||||
check("void foo() {\n"
|
||||
" printf(\"%n\", L\"s5W\");\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:2]: (warning) %n in format string (no. 1) requires 'int *' but the argument type is 'const wchar_t *'.\n", errout.str());
|
||||
|
||||
check("class foo {};\n"
|
||||
"void foo(const int* cpi, foo f, bar b, bar* bp, double d, int i, unsigned int u) {\n"
|
||||
" printf(\"%X\", f);\n"
|
||||
|
@ -1497,6 +1502,18 @@ private:
|
|||
"[test.cpp:6]: (warning) %x in format string (no. 1) requires 'unsigned int' but the argument type is 'const signed int *'.\n"
|
||||
"[test.cpp:8]: (warning) %X in format string (no. 1) requires 'unsigned int' but the argument type is 'bar *'.\n", errout.str());
|
||||
|
||||
check("class foo {};\n"
|
||||
"void foo() {\n"
|
||||
" printf(\"%x\", L\"s5W\");\n"
|
||||
" printf(\"%X\", L\"s5W\");\n"
|
||||
" printf(\"%c\", L\"s5W\");\n"
|
||||
" printf(\"%o\", L\"s5W\");\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (warning) %x in format string (no. 1) requires 'unsigned int' but the argument type is 'const wchar_t *'.\n"
|
||||
"[test.cpp:4]: (warning) %X in format string (no. 1) requires 'unsigned int' but the argument type is 'const wchar_t *'.\n"
|
||||
"[test.cpp:5]: (warning) %c in format string (no. 1) requires 'unsigned int' but the argument type is 'const wchar_t *'.\n"
|
||||
"[test.cpp:6]: (warning) %o in format string (no. 1) requires 'unsigned int' but the argument type is 'const wchar_t *'.\n", errout.str());
|
||||
|
||||
check("class foo {};\n"
|
||||
"void foo(const int* cpi, foo f, bar b, bar* bp, double d, unsigned int u, unsigned char uc) {\n"
|
||||
" printf(\"%i\", f);\n"
|
||||
|
@ -1515,6 +1532,14 @@ private:
|
|||
"[test.cpp:7]: (warning) %d in format string (no. 1) requires 'int' but the argument type is 'const signed int *'.\n"
|
||||
"[test.cpp:9]: (warning) %i in format string (no. 1) requires 'int' but the argument type is 'bar *'.\n", errout.str());
|
||||
|
||||
check("class foo {};\n"
|
||||
"void foo() {\n"
|
||||
" printf(\"%i\", L\"s5W\");\n"
|
||||
" printf(\"%d\", L\"s5W\");\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (warning) %i in format string (no. 1) requires 'int' but the argument type is 'const wchar_t *'.\n"
|
||||
"[test.cpp:4]: (warning) %d in format string (no. 1) requires 'int' but the argument type is 'const wchar_t *'.\n", errout.str());
|
||||
|
||||
check("class foo {};\n"
|
||||
"void foo(const int* cpi, foo f, bar b, bar* bp, double d, int i, bool bo) {\n"
|
||||
" printf(\"%u\", f);\n"
|
||||
|
@ -1533,6 +1558,12 @@ private:
|
|||
"[test.cpp:7]: (warning) %u in format string (no. 1) requires 'unsigned int' but the argument type is 'const signed int *'.\n"
|
||||
"[test.cpp:9]: (warning) %u in format string (no. 1) requires 'unsigned int' but the argument type is 'bar *'.\n", errout.str());
|
||||
|
||||
check("class foo {};\n"
|
||||
"void foo(const int* cpi, foo f, bar b, bar* bp, double d, int i, bool bo) {\n"
|
||||
" printf(\"%u\", L\"s5W\");\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (warning) %u in format string (no. 1) requires 'unsigned int' but the argument type is 'const wchar_t *'.\n", errout.str());
|
||||
|
||||
check("class foo {};\n"
|
||||
"void foo(const int* cpi, foo f, bar b, bar* bp, char c) {\n"
|
||||
" printf(\"%p\", f);\n"
|
||||
|
@ -1559,6 +1590,18 @@ private:
|
|||
"[test.cpp:5]: (warning) %f in format string (no. 1) requires 'double' but the argument type is 'const signed int *'.\n"
|
||||
"[test.cpp:6]: (warning) %G in format string (no. 1) requires 'double' but the argument type is 'bar *'.\n", errout.str());
|
||||
|
||||
check("class foo {};\n"
|
||||
"void foo() {\n"
|
||||
" printf(\"%e\", L\"s5W\");\n"
|
||||
" printf(\"%E\", L\"s5W\");\n"
|
||||
" printf(\"%f\", L\"s5W\");\n"
|
||||
" printf(\"%G\", L\"s5W\");\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (warning) %e in format string (no. 1) requires 'double' but the argument type is 'const wchar_t *'.\n"
|
||||
"[test.cpp:4]: (warning) %E in format string (no. 1) requires 'double' but the argument type is 'const wchar_t *'.\n"
|
||||
"[test.cpp:5]: (warning) %f in format string (no. 1) requires 'double' but the argument type is 'const wchar_t *'.\n"
|
||||
"[test.cpp:6]: (warning) %G in format string (no. 1) requires 'double' but the argument type is 'const wchar_t *'.\n", errout.str());
|
||||
|
||||
check("class foo;\n"
|
||||
"void foo(foo f) {\n"
|
||||
" printf(\"%u\", f);\n"
|
||||
|
|
Loading…
Reference in New Issue