Improve test coverage for invalid use of bool parameters

This commit is contained in:
Dmitry-Me 2019-11-22 18:11:38 +03:00
parent 5f2f19a646
commit 5a48ac0c6e
1 changed files with 10 additions and 2 deletions

View File

@ -432,8 +432,16 @@ private:
"}");
ASSERT_EQUALS("[test.cpp:2]: (error) Invalid memset() argument nr 3. A non-boolean value is required.\n", errout.str());
check("int f() { strtol(a,b,sizeof(a)!=12); }");
ASSERT_EQUALS("[test.cpp:1]: (error) Invalid strtol() argument nr 3. The value is 0 or 1 (boolean) but the valid values are '0,2:36'.\n", errout.str());
check("void boolArgZeroIsInvalidButOneIsValid(int param) {\n"
" void* buffer = calloc(param > 0, 10);\n"
" free(buffer);\n"
"}");
ASSERT_EQUALS("[test.cpp:2]: (error) Invalid calloc() argument nr 1. The value is 0 or 1 (boolean) but the valid values are '1:'.\n", errout.str());
check("void boolArgZeroIsValidButOneIsInvalid(int param) {\n"
" strtol(a, b, param > 0);\n"
"}");
ASSERT_EQUALS("[test.cpp:2]: (error) Invalid strtol() argument nr 3. The value is 0 or 1 (boolean) but the valid values are '0,2:36'.\n", errout.str());
check("int f() { strtol(a,b,1); }");
ASSERT_EQUALS("[test.cpp:1]: (error) Invalid strtol() argument nr 3. The value is 1 but the valid values are '0,2:36'.\n", errout.str());