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 "managermodeltranslatortest.h" 0008 #include "managermodeltranslator.h" 0009 #include <QJsonDocument> 0010 #include <QTest> 0011 QTEST_MAIN(ManagerModelTranslatorTest) 0012 ManagerModelTranslatorTest::ManagerModelTranslatorTest(QObject *parent) 0013 : QObject{parent} 0014 { 0015 } 0016 0017 void ManagerModelTranslatorTest::shouldHaveDefaultValues() 0018 { 0019 ManagerModelTranslator w; 0020 QVERIFY(w.translators().isEmpty()); 0021 QVERIFY(w.needDownloadModelList()); 0022 } 0023 0024 void ManagerModelTranslatorTest::shouldParseJson_data() 0025 { 0026 QTest::addColumn<QString>("fileName"); 0027 QTest::addColumn<int>("numberOfTranslator"); 0028 QTest::newRow("empty") << QStringLiteral("empty") << 0; 0029 QTest::newRow("fullmodels") << QStringLiteral("models") << 21; 0030 // 1 correct 1 invalid 0031 QTest::newRow("invalid") << QStringLiteral("invalid") << 1; 0032 } 0033 0034 void ManagerModelTranslatorTest::shouldParseJson() 0035 { 0036 QFETCH(QString, fileName); 0037 QFETCH(int, numberOfTranslator); 0038 const QString originalJsonFile = QLatin1String(BERGAMOT_DATA_DIR) + QStringLiteral("/modellanguages/") + fileName + QStringLiteral(".json"); 0039 ManagerModelTranslator w; 0040 w.loadModelList(originalJsonFile); 0041 QCOMPARE(w.translators().count(), numberOfTranslator); 0042 } 0043 0044 #include "moc_managermodeltranslatortest.cpp"