Fixes false positives in test suite, adds unit test for void-simplification

This commit is contained in:
PKEuS 2011-10-27 21:54:42 +03:00 committed by Reijo Tomperi
parent 49fd057e17
commit d6261debdf
2 changed files with 15 additions and 8 deletions

View File

@ -383,6 +383,9 @@ private:
TEST_CASE(simplifyFunctionReturn); TEST_CASE(simplifyFunctionReturn);
// void foo(void) -> void foo()
TEST_CASE(removeVoidFromFunction);
TEST_CASE(removeUnnecessaryQualification1); TEST_CASE(removeUnnecessaryQualification1);
TEST_CASE(removeUnnecessaryQualification2); TEST_CASE(removeUnnecessaryQualification2);
TEST_CASE(removeUnnecessaryQualification3); TEST_CASE(removeUnnecessaryQualification3);
@ -7346,6 +7349,10 @@ private:
ASSERT_EQUALS(expected, tok(code, false)); ASSERT_EQUALS(expected, tok(code, false));
} }
void removeVoidFromFunction() {
ASSERT_EQUALS("void foo ( ) ;", tok("void foo(void);"));
}
void removeUnnecessaryQualification1() { void removeUnnecessaryQualification1() {
const char code[] = "class Fred { Fred::Fred() {} };"; const char code[] = "class Fred { Fred::Fred() {} };";
const char expected[] = "class Fred { Fred ( ) { } } ;"; const char expected[] = "class Fred { Fred ( ) { } } ;";

View File

@ -5018,7 +5018,7 @@ private:
{ {
const char code[] = "class S { int function(void); };"; const char code[] = "class S { int function(void); };";
ASSERT_EQUALS("class S { int function ( void ) ; } ;", tokenizeAndStringify(code)); ASSERT_EQUALS("class S { int function ( ) ; } ;", tokenizeAndStringify(code));
checkSimplifyInitVar(code); checkSimplifyInitVar(code);
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
} }
@ -5032,7 +5032,7 @@ private:
{ {
const char code[] = "int function(void);"; const char code[] = "int function(void);";
ASSERT_EQUALS("int function ( void ) ;", tokenizeAndStringify(code)); ASSERT_EQUALS("int function ( ) ;", tokenizeAndStringify(code));
checkSimplifyInitVar(code); checkSimplifyInitVar(code);
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
} }
@ -5046,14 +5046,14 @@ private:
{ {
const char code[] = "extern int function(void);"; const char code[] = "extern int function(void);";
ASSERT_EQUALS("extern int function ( void ) ;", tokenizeAndStringify(code)); ASSERT_EQUALS("extern int function ( ) ;", tokenizeAndStringify(code));
checkSimplifyInitVar(code); checkSimplifyInitVar(code);
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
} }
{ {
const char code[] = "int function1(void); int function2(void);"; const char code[] = "int function1(void); int function2(void);";
ASSERT_EQUALS("int function1 ( void ) ; int function2 ( void ) ;", tokenizeAndStringify(code)); ASSERT_EQUALS("int function1 ( ) ; int function2 ( ) ;", tokenizeAndStringify(code));
checkSimplifyInitVar(code); checkSimplifyInitVar(code);
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
} }