File indexing completed on 2025-01-05 04:58:19

0001 /*
0002    SPDX-FileCopyrightText: 2016-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "addresseelineeditutiltest.h"
0008 #include "addressline/addresslineedit/addresseelineeditutil.h"
0009 #include <QTest>
0010 
0011 AddresseeLineEditUtilTest::AddresseeLineEditUtilTest(QObject *parent)
0012     : QObject(parent)
0013 {
0014 }
0015 
0016 AddresseeLineEditUtilTest::~AddresseeLineEditUtilTest() = default;
0017 
0018 void AddresseeLineEditUtilTest::shouldAdaptPasteMails_data()
0019 {
0020     QTest::addColumn<QString>("input");
0021     QTest::addColumn<QString>("output");
0022 
0023     QTest::newRow("empty") << QString() << QString();
0024     QTest::newRow("onemail") << QStringLiteral("foo@kde.org") << QStringLiteral("foo@kde.org");
0025     QTest::newRow("onemailwithat") << QStringLiteral("foo (at) kde.org") << QStringLiteral("foo@kde.org");
0026     QTest::newRow("text") << QStringLiteral("fookde.org") << QStringLiteral("fookde.org");
0027     QTest::newRow("onemailwithdot") << QStringLiteral("foo at kde dot org") << QStringLiteral("foo@kde.org");
0028     QTest::newRow("mailto") << QStringLiteral("mailto:foo@kde.org") << QStringLiteral("foo@kde.org");
0029     QTest::newRow("multimail") << QStringLiteral("foo@kde.org,\r\n     bla@kde.org,blo@kde.org") << QStringLiteral("foo@kde.org,      bla@kde.org,blo@kde.org");
0030     QTest::newRow("multimail-2") << QStringLiteral("foo@kde.org,\r\n     bla@kde.org,blo@kde.org,   ")
0031                                  << QStringLiteral("foo@kde.org,      bla@kde.org,blo@kde.org");
0032     QTest::newRow("multimail-3") << QStringLiteral("foo@kde.org,\r\n     bla@kde.org,blo@kde.org,\n")
0033                                  << QStringLiteral("foo@kde.org,      bla@kde.org,blo@kde.org");
0034     QTest::newRow("multimail-4") << QStringLiteral("foo@kde.org,\r\n     bla@kde.org,blo@kde.org,    \n")
0035                                  << QStringLiteral("foo@kde.org,      bla@kde.org,blo@kde.org");
0036     QTest::newRow("multimail-5") << QStringLiteral("foo (at) kde.org,\r\n     bla (at) kde.org,blo (at) kde.org")
0037                                  << QStringLiteral("foo@kde.org,      bla@kde.org,blo@kde.org");
0038     QTest::newRow("multimail-6") << QStringLiteral("mailto:foo@kde.org,\r\n     bla@kde.org,blo@kde.org")
0039                                  << QStringLiteral("foo@kde.org,      bla@kde.org,blo@kde.org");
0040     QTest::newRow("multimail-7") << QStringLiteral("bla <foo@kde.org>,\r\n     bli <bla@kde.org>,blo <blo@kde.org>")
0041                                  << QStringLiteral("bla <foo@kde.org>,      bli <bla@kde.org>,blo <blo@kde.org>");
0042     QTest::newRow("multimail-8") << QStringLiteral("\"bla, v\" <foo@kde.org>,\r\n     \"bli, u\" <bla@kde.org>,\"blo, k\" <blo@kde.org>")
0043                                  << QStringLiteral("\"bla, v\" <foo@kde.org>,      \"bli, u\" <bla@kde.org>,\"blo, k\" <blo@kde.org>");
0044 }
0045 
0046 void AddresseeLineEditUtilTest::shouldAdaptPasteMails()
0047 {
0048     QFETCH(QString, input);
0049     QFETCH(QString, output);
0050     QCOMPARE(PimCommon::AddresseeLineEditUtil::adaptPasteMails(input), output);
0051 }
0052 
0053 QTEST_MAIN(AddresseeLineEditUtilTest)
0054 
0055 #include "moc_addresseelineeditutiltest.cpp"