diff --git a/autotests/resourcetests/languageresources/testlanguagefiles.cpp b/autotests/resourcetests/languageresources/testlanguagefiles.cpp index f9bde8b..518a14c 100644 --- a/autotests/resourcetests/languageresources/testlanguagefiles.cpp +++ b/autotests/resourcetests/languageresources/testlanguagefiles.cpp @@ -1,63 +1,97 @@ /* * Copyright 2013 Oindrila Gupta * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "testlanguagefiles.h" #include "core/language.h" #include "core/unit.h" #include "core/phrase.h" #include "core/phoneme.h" +#include "core/phonemegroup.h" #include "core/resources/courseparser.h" #include #include #include #include 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 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; + 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) diff --git a/autotests/resourcetests/languageresources/testlanguagefiles.h b/autotests/resourcetests/languageresources/testlanguagefiles.h index e41a55f..7484c9b 100644 --- a/autotests/resourcetests/languageresources/testlanguagefiles.h +++ b/autotests/resourcetests/languageresources/testlanguagefiles.h @@ -1,51 +1,56 @@ /* * Copyright 2013 Oindrila Gupta * Copyright 2019 Andreas Cord-Landwehr * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef TESTLANGUAGEFILES_H #define TESTLANGUAGEFILES_H #include class TestLanguageFiles : public QObject { Q_OBJECT public: TestLanguageFiles(); private slots: /** * Called before every test case. */ void init(); /** * Called after every test case. */ void cleanup(); + /** + * Test language parser by loading German + */ + void loadGerman(); + /** * Test if id of each phoneme is unique in every language file. */ void checkIdUniqueness(); }; #endif