diff --git a/src/autotests/TerminalCharacterDecoderTest.cpp b/src/autotests/TerminalCharacterDecoderTest.cpp index 3930806a..e634793e 100644 --- a/src/autotests/TerminalCharacterDecoderTest.cpp +++ b/src/autotests/TerminalCharacterDecoderTest.cpp @@ -20,10 +20,8 @@ using namespace Konsole; -Character *TerminalCharacterDecoderTest::convertToCharacter(const QString &text, QVector renditions) +void TerminalCharacterDecoderTest::convertToCharacter(Character *charResult, const QString &text, QVector renditions) { - auto charResult = new Character[text.size()]; - // Force renditions size to match that of text; default will be DEFAULT_RENDITION. if (renditions.size() < text.size()) { renditions.resize(text.size()); @@ -32,7 +30,6 @@ Character *TerminalCharacterDecoderTest::convertToCharacter(const QString &text, charResult[i] = Character(text.at(i).unicode()); charResult[i].rendition = renditions.at(i); } - return charResult; } void TerminalCharacterDecoderTest::testPlainTextDecoder_data() @@ -61,15 +58,16 @@ void TerminalCharacterDecoderTest::testPlainTextDecoder() QFETCH(QString, result); TerminalCharacterDecoder *decoder = new PlainTextDecoder(); - auto testCharacters = convertToCharacter(text, renditions); + auto testCharacters = new Character[text.size()]; + convertToCharacter(testCharacters, text, renditions); QString outputString; QTextStream outputStream(&outputString); decoder->begin(&outputStream); decoder->decodeLine(testCharacters, text.size(), /* ignored */ LINE_DEFAULT); decoder->end(); - QCOMPARE(outputString, result); delete[] testCharacters; delete decoder; + QCOMPARE(outputString, result); } void TerminalCharacterDecoderTest::testHTMLDecoder_data() @@ -104,15 +102,16 @@ void TerminalCharacterDecoderTest::testHTMLDecoder() QFETCH(QString, result); TerminalCharacterDecoder *decoder = new HTMLDecoder(); - auto testCharacters = convertToCharacter(text, renditions); + auto testCharacters = new Character[text.size()]; + convertToCharacter(testCharacters, text, renditions); QString outputString; QTextStream outputStream(&outputString); decoder->begin(&outputStream); decoder->decodeLine(testCharacters, text.size(), /* ignored */ LINE_DEFAULT); decoder->end(); - QCOMPARE(outputString, result); delete[] testCharacters; delete decoder; + QCOMPARE(outputString, result); } QTEST_GUILESS_MAIN(TerminalCharacterDecoderTest) diff --git a/src/autotests/TerminalCharacterDecoderTest.h b/src/autotests/TerminalCharacterDecoderTest.h index 788cf6fb..06b04590 100644 --- a/src/autotests/TerminalCharacterDecoderTest.h +++ b/src/autotests/TerminalCharacterDecoderTest.h @@ -19,7 +19,7 @@ class TerminalCharacterDecoderTest : public QObject Q_OBJECT private Q_SLOTS: - Character *convertToCharacter(const QString &text, QVector renditions); + void convertToCharacter(Character *charResult, const QString &text, QVector renditions); void testPlainTextDecoder(); void testPlainTextDecoder_data(); void testHTMLDecoder();