Commit 0c2d25c6 authored by Laurent Montel's avatar Laurent Montel 😁

Fix using defaultForwardPrefixes. Add unittest

parent f1afd30a
......@@ -350,7 +350,7 @@ void StringUtilTest::test_isCryptoPart()
QVERIFY( !StringUtil::isCryptoPart( QLatin1String("application"), QLatin1String("foo"), QLatin1String("encrypted.asc") ) );
}
void StringUtilTest::test_stripOffMessagePrefix()
void StringUtilTest::test_stripOffMessagePrefixBenchmark()
{
const QString subject = QLatin1String( "Fwd: Hello World Subject" );
QBENCHMARK {
......@@ -383,3 +383,25 @@ void StringUtilTest::test_parseMailtoUrl()
QCOMPARE(StringUtil::parseMailtoUrl(url).value(QLatin1String("to")).split(QLatin1String(", "), QString::SkipEmptyParts).count(), numberOfTo);
}
void StringUtilTest::test_stripOffMessagePrefix_data()
{
QTest::addColumn<QString>( "subject" );
QTest::addColumn<QString>( "result" );
QTest::newRow("no strip needed") << QString::fromLatin1("Hello World Subject") << QString::fromLatin1("Hello World Subject");
QTest::newRow("No default reply forward") << QString::fromLatin1("AA: Hello World Subject") << QString::fromLatin1("AA: Hello World Subject");
QTest::newRow("Default Reply Re:") << QString::fromLatin1("Re: Hello World Subject") << QString::fromLatin1("Hello World Subject");
QTest::newRow("Default Forward FW:") << QString::fromLatin1("FW: Hello World Subject") << QString::fromLatin1("Hello World Subject");
QTest::newRow("Default Forward Fwd:") << QString::fromLatin1("Fwd: Hello World Subject") << QString::fromLatin1("Hello World Subject");
QTest::newRow("Default Reply Re :") << QString::fromLatin1("Re : Hello World Subject") << QString::fromLatin1("Hello World Subject");
QTest::newRow("Default Reply Re1:") << QString::fromLatin1("Re1: Hello World Subject") << QString::fromLatin1("Hello World Subject");
QTest::newRow("Default Reply Re[2]:") << QString::fromLatin1("Re[2]: Hello World Subject") << QString::fromLatin1("Hello World Subject");
}
void StringUtilTest::test_stripOffMessagePrefix()
{
QFETCH( QString, subject );
QFETCH( QString, result );
const QString subjectAfterStrip = StringUtil::stripOffPrefixes( subject );
QCOMPARE(subjectAfterStrip, result);
}
......@@ -31,9 +31,11 @@ class StringUtilTest : public QObject
void test_SmartQuote();
void test_signatureStripping();
void test_isCryptoPart();
void test_stripOffMessagePrefix();
void test_stripOffMessagePrefixBenchmark();
void test_parseMailtoUrl_data();
void test_parseMailtoUrl();
void test_stripOffMessagePrefix_data();
void test_stripOffMessagePrefix();
};
#endif
......@@ -1043,7 +1043,7 @@ QString stripOffPrefixes( const QString &subject )
QStringList forwardPrefixes = GlobalSettings::self()->forwardPrefixes();
if ( forwardPrefixes.isEmpty() )
forwardPrefixes = defaultReplyPrefixes;
forwardPrefixes = defaultForwardPrefixes;
const QStringList prefixRegExps = replyPrefixes + forwardPrefixes;
......
Markdown is supported
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