Commit 33963844 authored by Kurt Hindenburg's avatar Kurt Hindenburg
Browse files

Fix leaks when any test fails (coverity)

parent dfc4e172
Pipeline #152043 passed with stage
in 3 minutes and 26 seconds
......@@ -91,7 +91,7 @@ void KeyboardTranslatorTest::testEntryTextWildcards()
// Use FallbackKeyboardTranslator to test basic functionality
void KeyboardTranslatorTest::testFallback()
{
auto fallback = new FallbackKeyboardTranslator();
auto fallback = std::unique_ptr<FallbackKeyboardTranslator>(new FallbackKeyboardTranslator());
QCOMPARE(QStringLiteral("fallback"), fallback->name());
QCOMPARE(QStringLiteral("Fallback Keyboard Translator"), fallback->description());
......@@ -112,7 +112,6 @@ void KeyboardTranslatorTest::testFallback()
QVERIFY(entry.matches(Qt::Key_Tab, Qt::NoModifier, KeyboardTranslator::NoState));
QVERIFY(entry == fallback->findEntry(Qt::Key_Tab, Qt::NoModifier));
delete fallback;
}
void KeyboardTranslatorTest::testHexKeys()
......@@ -121,7 +120,7 @@ void KeyboardTranslatorTest::testHexKeys()
QVERIFY(linuxkeytab.exists());
QVERIFY(linuxkeytab.open(QIODevice::ReadOnly));
KeyboardTranslator *translator = new KeyboardTranslator(QStringLiteral("testtranslator"));
auto translator = std::unique_ptr<KeyboardTranslator>(new KeyboardTranslator(QStringLiteral("testtranslator")));
KeyboardTranslatorReader reader(&linuxkeytab);
while (reader.hasNextEntry()) {
......@@ -131,7 +130,6 @@ void KeyboardTranslatorTest::testHexKeys()
// A worthless check ATM
if (reader.parseError()) {
delete translator;
QFAIL("Parse failure");
}
......@@ -184,7 +182,6 @@ void KeyboardTranslatorTest::testHexKeys()
QVERIFY(!entry.matches(Qt::Key_Backspace, Qt::NoModifier, KeyboardTranslator::NoState));
QVERIFY(!(entry == translator->findEntry(Qt::Key_Backspace, Qt::NoModifier)));
delete translator;
}
QTEST_GUILESS_MAIN(KeyboardTranslatorTest)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment