Added testcase for ticket #3852

This commit is contained in:
Ettl Martin 2012-05-29 13:20:51 +02:00
parent 474dccf8ad
commit da5278f90c
1 changed files with 22 additions and 0 deletions

View File

@ -345,6 +345,7 @@ private:
TEST_CASE(enum27); // ticket #3005 (segmentation fault) TEST_CASE(enum27); // ticket #3005 (segmentation fault)
TEST_CASE(enum28); TEST_CASE(enum28);
TEST_CASE(enum29); // ticket #3747 (bitwise or value) TEST_CASE(enum29); // ticket #3747 (bitwise or value)
TEST_CASE(enum30); // ticket #3852 (false positive)
// remove "std::" on some standard functions // remove "std::" on some standard functions
TEST_CASE(removestd); TEST_CASE(removestd);
@ -6991,6 +6992,27 @@ private:
ASSERT_EQUALS("i = 3 == 3 ;", checkSimplifyEnum(code)); ASSERT_EQUALS("i = 3 == 3 ;", checkSimplifyEnum(code));
} }
void enum30() { // #3852 - false positive
const char code[] = "class TestIf\n"
"{\n"
"public:\n"
" enum class Foo\n"
" {\n"
" one = 0,\n"
" two = 1\n"
" };\n"
" enum class Bar\n"
" {\n"
" one = 0,\n"
" two = 1\n"
" };\n"
"};\n";
checkSimplifyEnum(code);
TODO_ASSERT_EQUALS("","[test.cpp:12] -> [test.cpp:7]: (style) Variable 'two' hides enumerator with same name\n", errout.str());
}
void removestd() { void removestd() {
ASSERT_EQUALS("; strcpy ( a , b ) ;", tok("; std::strcpy(a,b);")); ASSERT_EQUALS("; strcpy ( a , b ) ;", tok("; std::strcpy(a,b);"));
ASSERT_EQUALS("; strcat ( a , b ) ;", tok("; std::strcat(a,b);")); ASSERT_EQUALS("; strcat ( a , b ) ;", tok("; std::strcat(a,b);"));