From 95851454cc6987da0daa0fd097fa056dab98b1a3 Mon Sep 17 00:00:00 2001 From: Thomas Jarosch Date: Sun, 6 Nov 2011 18:19:27 +0100 Subject: [PATCH] Unit test for Token::isExtendedOp() and Token::isAssignmentOp() --- test/testtoken.cpp | 91 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/test/testtoken.cpp b/test/testtoken.cpp index fc60b5647..0ed262969 100644 --- a/test/testtoken.cpp +++ b/test/testtoken.cpp @@ -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");