More test cases for pointer sign detection

This commit is contained in:
Dmitry-Me 2014-09-04 15:51:18 +04:00
parent 800b57d87e
commit 7d9342d16a
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"