Unit test for %varid% match

Also run astyle.
This commit is contained in:
Thomas Jarosch 2011-11-06 18:37:00 +01:00
parent 05c4b97bbe
commit d7ce892c06
1 changed files with 14 additions and 4 deletions

View File

@ -46,6 +46,7 @@ private:
TEST_CASE(matchNothingOrAnyNotElse);
TEST_CASE(matchType);
TEST_CASE(matchStr);
TEST_CASE(matchVarid);
TEST_CASE(matchNumeric);
TEST_CASE(matchBoolean);
TEST_CASE(matchOr);
@ -200,8 +201,7 @@ private:
ASSERT_EQUALS(false, Token::Match(ifSemicolonElse.tokens(), "if ; !!else"));
}
void matchType()
{
void matchType() {
givenACodeSampleToTokenize type("abc");
ASSERT_EQUALS(true, Token::Match(type.tokens(), "%type%"));
@ -214,8 +214,7 @@ private:
ASSERT_EQUALS(false, Token::Match(noType.tokens(), "%type%"));
}
void matchStr()
{
void matchStr() {
givenACodeSampleToTokenize noStr1("abc");
ASSERT_EQUALS(false, Token::Match(noStr1.tokens(), "%str%"));
@ -226,6 +225,17 @@ private:
ASSERT_EQUALS(true, Token::Match(str.tokens(), "%str%"));
}
void matchVarid() {
givenACodeSampleToTokenize var("int a ; int b ;");
ASSERT_EQUALS(false, Token::Match(var.tokens(), "%type% %varid% ; %type% %var%", 0));
ASSERT_EQUALS(true, Token::Match(var.tokens(), "%type% %varid% ; %type% %var%", 1));
ASSERT_EQUALS(true, Token::Match(var.tokens(), "%type% %var% ; %type% %varid%", 2));
// Try to match two different varids in one match call
ASSERT_EQUALS(false, Token::Match(var.tokens(), "%type% %varid% ; %type% %varid%", 2));
}
void matchNumeric() {
givenACodeSampleToTokenize nonNumeric("abc");
ASSERT_EQUALS(false, Token::Match(nonNumeric.tokens(), "%num%"));