Fixed memory leaks in teststl

This commit is contained in:
Alexander Mai 2013-04-07 18:43:18 +02:00 committed by PKEuS
parent cd770fb106
commit 14fc140592
1 changed files with 36 additions and 36 deletions

View File

@ -122,54 +122,54 @@ private:
void multiCompare() const { void multiCompare() const {
// Test for found // Test for found
Token *one = new Token(0); Token one(0);
one->str("one"); one.str("one");
ASSERT_EQUALS(1, Token::multiCompare(one, "one|two", "one")); ASSERT_EQUALS(1, Token::multiCompare(&one, "one|two", "one"));
Token *two = new Token(0); Token two(0);
two->str("two"); two.str("two");
ASSERT_EQUALS(1, Token::multiCompare(two, "one|two", "two")); ASSERT_EQUALS(1, Token::multiCompare(&two, "one|two", "two"));
ASSERT_EQUALS(1, Token::multiCompare(two, "verybig|two|", "two")); ASSERT_EQUALS(1, Token::multiCompare(&two, "verybig|two|", "two"));
// Test for empty string found // Test for empty string found
Token *notfound = new Token(0); Token notfound(0);
notfound->str("notfound"); notfound.str("notfound");
ASSERT_EQUALS(0, Token::multiCompare(notfound, "|one|two", "notfound")); ASSERT_EQUALS(0, Token::multiCompare(&notfound, "|one|two", "notfound"));
ASSERT_EQUALS(0, Token::multiCompare(notfound, "one||two", "notfound")); ASSERT_EQUALS(0, Token::multiCompare(&notfound, "one||two", "notfound"));
ASSERT_EQUALS(0, Token::multiCompare(notfound, "one|two|", "notfound")); ASSERT_EQUALS(0, Token::multiCompare(&notfound, "one|two|", "notfound"));
// Test for not found // Test for not found
ASSERT_EQUALS(static_cast<unsigned int>(-1), static_cast<unsigned int>(Token::multiCompare(notfound, "one|two", "notfound"))); ASSERT_EQUALS(static_cast<unsigned int>(-1), static_cast<unsigned int>(Token::multiCompare(&notfound, "one|two", "notfound")));
Token *s = new Token(0); Token s(0);
s->str("s"); s.str("s");
ASSERT_EQUALS(static_cast<unsigned int>(-1), static_cast<unsigned int>(Token::multiCompare(s, "verybig|two", "s"))); ASSERT_EQUALS(static_cast<unsigned int>(-1), static_cast<unsigned int>(Token::multiCompare(&s, "verybig|two", "s")));
Token *ne = new Token(0); Token ne(0);
ne->str("ne"); ne.str("ne");
ASSERT_EQUALS(static_cast<unsigned int>(-1), static_cast<unsigned int>(Token::multiCompare(ne, "one|two", "ne"))); ASSERT_EQUALS(static_cast<unsigned int>(-1), static_cast<unsigned int>(Token::multiCompare(&ne, "one|two", "ne")));
Token *a = new Token(0); Token a(0);
a->str("a"); a.str("a");
ASSERT_EQUALS(static_cast<unsigned int>(-1), static_cast<unsigned int>(Token::multiCompare(a, "abc|def", "a"))); ASSERT_EQUALS(static_cast<unsigned int>(-1), static_cast<unsigned int>(Token::multiCompare(&a, "abc|def", "a")));
Token *abcd = new Token(0); Token abcd(0);
abcd->str("abcd"); abcd.str("abcd");
ASSERT_EQUALS(static_cast<unsigned int>(-1), static_cast<unsigned int>(Token::multiCompare(abcd, "abc|def", "abcd"))); ASSERT_EQUALS(static_cast<unsigned int>(-1), static_cast<unsigned int>(Token::multiCompare(&abcd, "abc|def", "abcd")));
Token *def = new Token(0); Token def(0);
def->str("default"); def.str("default");
ASSERT_EQUALS(static_cast<unsigned int>(-1), static_cast<unsigned int>(Token::multiCompare(def, "abc|def", "default"))); ASSERT_EQUALS(static_cast<unsigned int>(-1), static_cast<unsigned int>(Token::multiCompare(&def, "abc|def", "default")));
// %op% // %op%
Token *plus = new Token(0); Token plus(0);
plus->str("+"); plus.str("+");
ASSERT_EQUALS(1, Token::multiCompare(plus, "one|%op%", "+")); ASSERT_EQUALS(1, Token::multiCompare(&plus, "one|%op%", "+"));
ASSERT_EQUALS(1, Token::multiCompare(plus, "%op%|two", "+")); ASSERT_EQUALS(1, Token::multiCompare(&plus, "%op%|two", "+"));
Token *x = new Token(0); Token x(0);
x->str("x"); x.str("x");
ASSERT_EQUALS(-1, Token::multiCompare(x, "one|%op%", "x")); ASSERT_EQUALS(-1, Token::multiCompare(&x, "one|%op%", "x"));
ASSERT_EQUALS(-1, Token::multiCompare(x, "%op%|two", "x")); ASSERT_EQUALS(-1, Token::multiCompare(&x, "%op%|two", "x"));
} }
void multiCompare2() const { // #3294 void multiCompare2() const { // #3294