File indexing completed on 2024-12-22 04:28:07

0001 /*
0002   SPDX-FileCopyrightText: 2020-2024 Laurent Montel <montel@kde.org>
0003 
0004   SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "importkmailautocorrectiontest.h"
0008 #include "import/importkmailautocorrection.h"
0009 #include <QTest>
0010 QTEST_MAIN(ImportKMailAutocorrectionTest)
0011 
0012 ImportKMailAutocorrectionTest::ImportKMailAutocorrectionTest(QObject *parent)
0013     : QObject(parent)
0014 {
0015 }
0016 
0017 void ImportKMailAutocorrectionTest::shouldHaveDefaultValues()
0018 {
0019     TextAutoCorrectionCore::ImportKMailAutocorrection import;
0020     QVERIFY(import.upperCaseExceptions().isEmpty());
0021     QVERIFY(import.twoUpperLetterExceptions().isEmpty());
0022     QVERIFY(import.autocorrectEntries().isEmpty());
0023     QVERIFY(import.superScriptEntries().isEmpty());
0024 
0025     QCOMPARE(import.typographicSingleQuotes().begin, QChar());
0026     QCOMPARE(import.typographicSingleQuotes().end, QChar());
0027     QCOMPARE(import.typographicDoubleQuotes().begin, QChar());
0028     QCOMPARE(import.typographicDoubleQuotes().end, QChar());
0029 
0030     QCOMPARE(import.maxFindStringLenght(), 0);
0031     QCOMPARE(import.minFindStringLenght(), 0);
0032 }
0033 
0034 void ImportKMailAutocorrectionTest::shouldLoadFile()
0035 {
0036     const QString originalFile = QLatin1String(AUTOCORRECTION_DATA_DIR) + QStringLiteral("/custom-fr.xml");
0037     TextAutoCorrectionCore::ImportKMailAutocorrection import;
0038     QString messageError;
0039     QVERIFY(import.import(originalFile, messageError));
0040     QCOMPARE(import.typographicSingleQuotes().begin, QStringLiteral("‘"));
0041     QCOMPARE(import.typographicSingleQuotes().end, QStringLiteral("’"));
0042     QCOMPARE(import.typographicDoubleQuotes().begin, QStringLiteral("“"));
0043     QCOMPARE(import.typographicDoubleQuotes().end, QStringLiteral("”"));
0044 
0045     const auto resultTwoUpperLetterExceptions = import.twoUpperLetterExceptions();
0046     QCOMPARE(resultTwoUpperLetterExceptions.count(), 21);
0047 
0048     const auto resultUpperCaseExceptions = import.upperCaseExceptions();
0049     QCOMPARE(resultUpperCaseExceptions.count(), 45);
0050 
0051     const auto resultAutocorrectEntries = import.autocorrectEntries();
0052     QCOMPARE(resultAutocorrectEntries.count(), 1221);
0053 }
0054 
0055 #include "moc_importkmailautocorrectiontest.cpp"