From 0b97f37736acdef7f4f6a3b8377432f8f8ab7ecf Mon Sep 17 00:00:00 2001 From: Dmitry-Me Date: Fri, 1 Nov 2019 18:41:10 +0300 Subject: [PATCH] Improve test coverage --- test/testother.cpp | 8 ++++++++ test/testsizeof.cpp | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/test/testother.cpp b/test/testother.cpp index 584205787..83e89076a 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -6966,6 +6966,14 @@ private: "}"); ASSERT_EQUALS("[test.cpp:3]: (warning) Storing getchar() return value in char variable and then comparing with EOF.\n", errout.str()); + check("void f() {\n" + " unsigned char c;\n" + " while( EOF != ( c = getchar() ) )\n" + " {\n" + " }\n" + "}"); + ASSERT_EQUALS("[test.cpp:3]: (warning) Storing getchar() return value in char variable and then comparing with EOF.\n", errout.str()); + check("void f() {\n" " int i; i = getchar();\n" " while( i != EOF)\n" diff --git a/test/testsizeof.cpp b/test/testsizeof.cpp index 769a0d507..743cbb3d5 100644 --- a/test/testsizeof.cpp +++ b/test/testsizeof.cpp @@ -746,9 +746,11 @@ private: " void* p = malloc(10);\n" " int* p2 = p + 4;\n" " int* p3 = p - 1;\n" + " int* p4 = 1 + p;\n" "}"); ASSERT_EQUALS("[test.cpp:3]: (portability) 'p' is of type 'void *'. When using void pointers in calculations, the behaviour is undefined.\n" - "[test.cpp:4]: (portability) 'p' is of type 'void *'. When using void pointers in calculations, the behaviour is undefined.\n", errout.str()); + "[test.cpp:4]: (portability) 'p' is of type 'void *'. When using void pointers in calculations, the behaviour is undefined.\n" + "[test.cpp:5]: (portability) 'p' is of type 'void *'. When using void pointers in calculations, the behaviour is undefined.\n", errout.str()); check("void f() {\n" " void* p1 = malloc(10);\n"