TestDivision: Added two tests of unsigned division when negative constant is used.

This commit is contained in:
Daniel Marjamäki 2008-10-06 08:52:46 +00:00
parent 5115420809
commit 3d14bbea56
1 changed files with 22 additions and 0 deletions

View File

@ -39,6 +39,8 @@ public:
TEST_CASE( division3 );
TEST_CASE( division4 );
TEST_CASE( division5 );
TEST_CASE( division6 );
TEST_CASE( division7 );
}
void division1()
@ -101,6 +103,26 @@ public:
);
ASSERT_EQUALS( std::string(""), errout.str() );
}
void division6()
{
check( "void foo()\n"
"{\n"
" unsigned int val = 32;\n"
" int i = val / -2;\n"
);
ASSERT_EQUALS( std::string("[test.cpp:4]: The division result will be wrong\n"), errout.str() );
}
void division7()
{
check( "void foo()\n"
"{\n"
" unsigned int val = 32;\n"
" int i = -96 / val;\n"
);
ASSERT_EQUALS( std::string("[test.cpp:4]: The division result will be wrong\n"), errout.str() );
}
};
REGISTER_FIXTURE( TestDivision )