Skip to content

Commit

Permalink
Added test for #11175 - FN: zerodiv (danmar#6550)
Browse files Browse the repository at this point in the history
  • Loading branch information
orbitcowboy committed Jun 26, 2024
1 parent c85f889 commit 781ef2a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/testother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class TestOther : public TestFixture {
TEST_CASE(zeroDiv17); // #9931
TEST_CASE(zeroDiv18);
TEST_CASE(zeroDiv19);
TEST_CASE(zeroDiv20); // #11175

TEST_CASE(zeroDivCond); // division by zero / useless condition

Expand Down Expand Up @@ -661,6 +662,16 @@ class TestOther : public TestFixture {
ASSERT_EQUALS("[test.cpp:3]: (error) Division by zero.\n", errout_str());
}

void zeroDiv20()
{
check("uint16_t f(void)\n" // #11175
"{\n"
" uint16_t x = 0xFFFFU;\n" // UINT16_MAX=0xFFFF
" return 42/(++x);\n"
"}");
ASSERT_EQUALS("[test.cpp:4]: (error) Division by zero.\n", errout_str());
}

void zeroDivCond() {
check("void f(unsigned int x) {\n"
" int y = 17 / x;\n"
Expand Down

0 comments on commit 781ef2a

Please sign in to comment.