File indexing completed on 2024-11-24 04:16:54

0001 /*
0002   SPDX-FileCopyrightText: 2023-2024 Laurent Montel <montel.org>
0003 
0004   SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "bergamotengineutilstest.h"
0008 #include "bergamotengineutils.h"
0009 #include <QTest>
0010 
0011 QTEST_GUILESS_MAIN(BergamotEngineUtilsTest)
0012 BergamotEngineUtilsTest::BergamotEngineUtilsTest(QObject *parent)
0013     : QObject{parent}
0014 {
0015 }
0016 
0017 void BergamotEngineUtilsTest::shouldDefaultBergamotRepository()
0018 {
0019     QCOMPARE(BergamotEngineUtils::defaultBergamotRepository(), QStringLiteral("https://translatelocally.com/models.json"));
0020     QCOMPARE(BergamotEngineUtils::groupName(), QStringLiteral("BergamotTranslator"));
0021     QCOMPARE(BergamotEngineUtils::coreNumberKey(), QStringLiteral("CoreNumber"));
0022     QCOMPARE(BergamotEngineUtils::memoryByThreadKey(), QStringLiteral("MemoryByThread"));
0023     QCOMPARE(BergamotEngineUtils::useLocalCacheKey(), QStringLiteral("UseLocalKey"));
0024 }
0025 
0026 void BergamotEngineUtilsTest::shouldExtractInfoFromLanguageLocallyStored()
0027 {
0028     {
0029         const QString originalDir = QLatin1String(BERGAMOT_DATA_DIR) + QStringLiteral("/test-stored-languages/test1");
0030         const QVector<BergamotEngineUtils::LanguageInstalled> list = BergamotEngineUtils::languageLocallyStored(originalDir);
0031         QCOMPARE(list.count(), 0);
0032     }
0033     {
0034         const QString originalDir = QLatin1String(BERGAMOT_DATA_DIR) + QStringLiteral("/test-stored-languages/test2");
0035         const QVector<BergamotEngineUtils::LanguageInstalled> list = BergamotEngineUtils::languageLocallyStored(originalDir);
0036         QCOMPARE(list.count(), 3);
0037     }
0038 }
0039 
0040 #include "moc_bergamotengineutilstest.cpp"