From 7d9342d16a5bb7cf8aab91f56c938f1e3c95b144 Mon Sep 17 00:00:00 2001 From: Dmitry-Me Date: Thu, 4 Sep 2014 15:51:18 +0400 Subject: [PATCH] More test cases for pointer sign detection --- test/testother.cpp | 49 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/test/testother.cpp b/test/testother.cpp index 65ebc4613..c693919e2 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -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"