Skip to content

Commit

Permalink
#12158: add another test and a small fix
Browse files Browse the repository at this point in the history
  • Loading branch information
olabetskyi committed Dec 13, 2023
1 parent 4d99821 commit bb361c7
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions test/testother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class TestOther : public TestFixture {
TEST_CASE(varScope34);
TEST_CASE(varScope35);
TEST_CASE(varScope36); // #12158
TEST_CASE(varScope37); // #12158

TEST_CASE(oldStylePointerCast);
TEST_CASE(invalidPointerCast);
Expand Down Expand Up @@ -1675,9 +1676,24 @@ class TestOther : public TestFixture {
" if ( value > 100U ) { }\n"
" else if( value > 50U ) { }\n"
" else{\n"
" for( i = 0U; i < 5U; i++ ) {}"
" }"
"}", nullptr, false);
" for( i = 0U; i < 5U; i++ ) {}\n"
" }\n"
"}\n", nullptr, false);
ASSERT_EQUALS("[test.cpp:2]: (style) The scope of the variable 'i' can be reduced.\n", errout.str());
}

void varScope37() {
// #12158
check("void f( uint32_t value ) {\n"
" uint32_t i = 0U;\n"
" if ( value > 100U ) { }\n"
" else {\n"
" if( value > 50U ) { }\n"
" else{\n"
" for( i = 0U; i < 5U; i++ ) {}\n"
" }\n"
" }\n"
"}\n", nullptr, false);
ASSERT_EQUALS("[test.cpp:2]: (style) The scope of the variable 'i' can be reduced.\n", errout.str());
}

Expand Down

0 comments on commit bb361c7

Please sign in to comment.