1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
/*
SPDX-FileCopyrightText: 2013 Oindrila Gupta <oindrila.gupta92@gmail.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
#include "testlanguagefiles.h"
#include "core/language.h"
#include "core/phoneme.h"
#include "core/phonemegroup.h"
#include "core/phrase.h"
#include "core/resources/courseparser.h"
#include "core/unit.h"
#include <QDebug>
#include <QDirIterator>
#include <QTest>
#include <QUrl>
TestLanguageFiles::TestLanguageFiles()
{
}
void TestLanguageFiles::init()
{
// TODO initialization of test case
}
void TestLanguageFiles::cleanup()
{
// TODO cleanup after test run
}
void TestLanguageFiles::loadGerman()
{
QUrl file = QUrl::fromLocalFile(":/artikulate/languages/de.xml");
auto language = Language::create(file);
QCOMPARE(language->id(), "de");
QCOMPARE(language->title(), "Deutsch");
QCOMPARE(language->i18nTitle(), "German");
std::shared_ptr<PhonemeGroup> group;
for (auto iter : language->phonemeGroups()) {
if (iter->id() == "monophthonge") {
group = iter;
break;
}
}
QVERIFY(group);
QCOMPARE(group->id(), "monophthonge");
QCOMPARE(group->title(), "Vokalsystem Monophthonge");
QCOMPARE(group->description(), "Monophthonge");
std::shared_ptr<Phoneme> phoneme;
for (auto iter : language->phonemes()) {
if (iter->id() == "a") {
phoneme = iter;
break;
}
}
QVERIFY(phoneme);
QCOMPARE(phoneme->id(), "a");
QCOMPARE(phoneme->title(), "[a] Kamm");
}
void TestLanguageFiles::checkIdUniqueness()
{
QDirIterator iter(QDir(":/artikulate/languages/"));
while (iter.hasNext()) {
const QString &file = iter.next();
qDebug() << "File being parsed: " << file;
QStringList idList;
auto language = Language::create(QUrl::fromLocalFile(file));
for (auto phoneme : language->phonemes()) {
QVERIFY2(!idList.contains(phoneme->id()), "Phoneme ID used more than once in the tested file");
idList.append(phoneme->id());
}
}
}
QTEST_GUILESS_MAIN(TestLanguageFiles)
|