Unit test for Token::isExtendedOp() and Token::isAssignmentOp()

This commit is contained in:
Thomas Jarosch 2011-11-06 18:19:27 +01:00
parent 19c9c97608
commit 95851454cc
1 changed files with 91 additions and 0 deletions

View File

@ -49,6 +49,9 @@ private:
TEST_CASE(matchOr);
TEST_CASE(matchOp);
TEST_CASE(isExtendedOp);
TEST_CASE(isAssignmentOp);
TEST_CASE(updateProperties)
TEST_CASE(updatePropertiesConcatStr)
TEST_CASE(isNameGuarantees1)
@ -288,6 +291,94 @@ private:
ASSERT_EQUALS(true, Token::Match(givenACodeSampleToTokenize("!").tokens(), "%op%"));
}
void isExtendedOp() {
Token tok(NULL);
// Normal isOp()
tok.str("<<");
ASSERT_EQUALS(true, tok.isExtendedOp());
tok.str(">>");
ASSERT_EQUALS(true, tok.isExtendedOp());
tok.str("+");
ASSERT_EQUALS(true, tok.isExtendedOp());
tok.str("-");
ASSERT_EQUALS(true, tok.isExtendedOp());
tok.str("*");
ASSERT_EQUALS(true, tok.isExtendedOp());
tok.str("/");
ASSERT_EQUALS(true, tok.isExtendedOp());
tok.str("%");
ASSERT_EQUALS(true, tok.isExtendedOp());
tok.str("&&");
ASSERT_EQUALS(true, tok.isExtendedOp());
tok.str("||");
ASSERT_EQUALS(true, tok.isExtendedOp());
tok.str("==");
ASSERT_EQUALS(true, tok.isExtendedOp());
tok.str("!=");
ASSERT_EQUALS(true, tok.isExtendedOp());
tok.str("<");
ASSERT_EQUALS(true, tok.isExtendedOp());
tok.str("<=");
ASSERT_EQUALS(true, tok.isExtendedOp());
tok.str(">");
ASSERT_EQUALS(true, tok.isExtendedOp());
tok.str(">=");
ASSERT_EQUALS(true, tok.isExtendedOp());
tok.str("&");
ASSERT_EQUALS(true, tok.isExtendedOp());
tok.str("|");
ASSERT_EQUALS(true, tok.isExtendedOp());
tok.str("^");
ASSERT_EQUALS(true, tok.isExtendedOp());
tok.str("~");
ASSERT_EQUALS(true, tok.isExtendedOp());
tok.str("!");
ASSERT_EQUALS(true, tok.isExtendedOp());
// Extended operators
tok.str(",");
ASSERT_EQUALS(true, tok.isExtendedOp());
tok.str("[");
ASSERT_EQUALS(true, tok.isExtendedOp());
tok.str("]");
ASSERT_EQUALS(true, tok.isExtendedOp());
tok.str("(");
ASSERT_EQUALS(true, tok.isExtendedOp());
tok.str(")");
ASSERT_EQUALS(true, tok.isExtendedOp());
tok.str("?");
ASSERT_EQUALS(true, tok.isExtendedOp());
tok.str(":");
}
void isAssignmentOp() {
Token tok(NULL);
tok.str("=");
ASSERT_EQUALS(true, tok.isAssignmentOp());
tok.str("+=");
ASSERT_EQUALS(true, tok.isAssignmentOp());
tok.str("-=");
ASSERT_EQUALS(true, tok.isAssignmentOp());
tok.str("*=");
ASSERT_EQUALS(true, tok.isAssignmentOp());
tok.str("/=");
ASSERT_EQUALS(true, tok.isAssignmentOp());
tok.str("%=");
ASSERT_EQUALS(true, tok.isAssignmentOp());
tok.str("&=");
ASSERT_EQUALS(true, tok.isAssignmentOp());
tok.str("^=");
ASSERT_EQUALS(true, tok.isAssignmentOp());
tok.str("|=");
ASSERT_EQUALS(true, tok.isAssignmentOp());
tok.str("<<=");
ASSERT_EQUALS(true, tok.isAssignmentOp());
tok.str(">>=");
ASSERT_EQUALS(true, tok.isAssignmentOp());
}
void updateProperties() {
Token tok(NULL);
tok.str("foobar");