Merge pull request #418 from Dmitry-Me/moreTestsForPointerSign

More test cases for pointer sign detection
This commit is contained in:
amai2012 2014-09-04 22:38:31 +02:00
commit 36e53369cb
1 changed files with 49 additions and 0 deletions

View File

@ -4474,6 +4474,34 @@ private:
"}");
ASSERT_EQUALS("", errout.str());
check_signOfUnsignedVariable(
"bool foo(int* x, int* y) {\n"
" if (x - y < 0)"
" bar();\n"
"}");
ASSERT_EQUALS("", errout.str());
check_signOfUnsignedVariable(
"bool foo(int* x, int* y) {\n"
" if (x - y <= 0)"
" bar();\n"
"}");
ASSERT_EQUALS("", errout.str());
check_signOfUnsignedVariable(
"bool foo(int* x, int* y) {\n"
" if (x - y > 0)"
" bar();\n"
"}");
ASSERT_EQUALS("", errout.str());
check_signOfUnsignedVariable(
"bool foo(int* x, int* y) {\n"
" if (x - y >= 0)"
" bar();\n"
"}");
ASSERT_EQUALS("", errout.str());
check_signOfUnsignedVariable(
"bool foo(Bar* x) {\n"
" if (0 <= x)"
@ -4495,6 +4523,20 @@ private:
"}");
ASSERT_EQUALS("", errout.str());
check_signOfUnsignedVariable(
"bool foo(Bar* x) {\n"
" if (0 <= x->y)"
" bar();\n"
"}");
ASSERT_EQUALS("", errout.str());
check_signOfUnsignedVariable(
"bool foo(Bar* x, Bar* y) {\n"
" if (0 <= x->y - y->y )"
" bar();\n"
"}");
ASSERT_EQUALS("", errout.str());
check_signOfUnsignedVariable(
"bool foo(Bar* x) {\n"
" if (0 > x)"
@ -4516,6 +4558,13 @@ private:
"}");
ASSERT_EQUALS("", errout.str());
check_signOfUnsignedVariable(
"bool foo(Bar* x) {\n"
" if (0 > x->y)"
" bar();\n"
"}");
ASSERT_EQUALS("", errout.str());
check_signOfUnsignedVariable(
"void foo() {\n"
" int (*t)(void *a, void *b);\n"