1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
/*
SPDX-FileCopyrightText: 2024 Volker Krause <vkrause@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include <KMime/Message>
#include <QFile>
#include <QTest>
using namespace Qt::Literals;
class MessageParserBenchmark : public QObject
{
Q_OBJECT
private Q_SLOTS:
void testPlainTextParse()
{
QFile file(QLatin1StringView(TEST_DATA_DIR "/plain-text-body.mbox"));
QVERIFY(file.open(QIODevice::ReadOnly));
const QByteArray data = KMime::CRLFtoLF(file.readAll());
QBENCHMARK {
auto msg = std::make_unique<KMime::Message>();
msg->setContent(data);
msg->parse();
QVERIFY(msg->subject(false));
QCOMPARE(msg->subject()->asUnicodeString(), "New Project: Kool Desktop Environment (KDE)"_L1);
QVERIFY(msg->decodedText().contains("Kool Desktop Environment"_L1));
}
}
};
QTEST_GUILESS_MAIN(MessageParserBenchmark)
#include "messageparserbenchmark.moc"
|