Fix ticket #305 (Negative value passed to ASSERT_EQUALS)

http://apps.sourceforge.net/trac/cppcheck/ticket/305
Moved also test case from testtokenizer to testtoken.
This commit is contained in:
Reijo Tomperi 2009-05-12 21:28:02 +03:00
parent e83db8ac7b
commit 24d96b188e
2 changed files with 20 additions and 24 deletions

View File

@ -34,7 +34,7 @@ private:
void run()
{
TEST_CASE(nextprevious);
TEST_CASE(multiCompare);
}
void nextprevious()
@ -59,7 +59,26 @@ private:
Tokenizer::deleteTokens(token);
}
void multiCompare()
{
// Test for found
ASSERT_EQUALS(1, Token::multiCompare("one|two", "one"));
ASSERT_EQUALS(1, Token::multiCompare("one|two", "two"));
ASSERT_EQUALS(1, Token::multiCompare("verybig|two|", "two"));
// Test for empty string found
ASSERT_EQUALS(0, Token::multiCompare("|one|two", "notfound"));
ASSERT_EQUALS(0, Token::multiCompare("one||two", "notfound"));
ASSERT_EQUALS(0, Token::multiCompare("one|two|", "notfound"));
// Test for not found
ASSERT_EQUALS(static_cast<unsigned int>(-1), static_cast<unsigned int>(Token::multiCompare("one|two", "notfound")));
ASSERT_EQUALS(static_cast<unsigned int>(-1), static_cast<unsigned int>(Token::multiCompare("verybig|two", "s")));
ASSERT_EQUALS(static_cast<unsigned int>(-1), static_cast<unsigned int>(Token::multiCompare("one|two", "ne")));
ASSERT_EQUALS(static_cast<unsigned int>(-1), static_cast<unsigned int>(Token::multiCompare("abc|def", "a")));
ASSERT_EQUALS(static_cast<unsigned int>(-1), static_cast<unsigned int>(Token::multiCompare("abc|def", "abcd")));
ASSERT_EQUALS(static_cast<unsigned int>(-1), static_cast<unsigned int>(Token::multiCompare("abc|def", "default")));
}
};
REGISTER_TEST(TestTOKEN)

View File

@ -93,8 +93,6 @@ private:
TEST_CASE(simplifyKnownVariables9);
TEST_CASE(simplifyKnownVariables10);
TEST_CASE(multiCompare);
TEST_CASE(match1);
TEST_CASE(match2);
@ -742,27 +740,6 @@ private:
}
}
void multiCompare()
{
// Test for found
ASSERT_EQUALS(1, Token::multiCompare("one|two", "one"));
ASSERT_EQUALS(1, Token::multiCompare("one|two", "two"));
ASSERT_EQUALS(1, Token::multiCompare("verybig|two|", "two"));
// Test for empty string found
ASSERT_EQUALS(0, Token::multiCompare("|one|two", "notfound"));
ASSERT_EQUALS(0, Token::multiCompare("one||two", "notfound"));
ASSERT_EQUALS(0, Token::multiCompare("one|two|", "notfound"));
// Test for not found
ASSERT_EQUALS(-1, Token::multiCompare("one|two", "notfound"));
ASSERT_EQUALS(-1, Token::multiCompare("verybig|two", "s"));
ASSERT_EQUALS(-1, Token::multiCompare("one|two", "ne"));
ASSERT_EQUALS(-1, Token::multiCompare("abc|def", "a"));
ASSERT_EQUALS(-1, Token::multiCompare("abc|def", "abcd"));
ASSERT_EQUALS(-1, Token::multiCompare("abc|def", "default"));
}
void match1()
{
// Match "%var% | %var%"