File: testlanguagefiles.cpp

package info (click to toggle)
artikulate 4%3A25.04.0-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 3,936 kB
  • sloc: cpp: 11,286; xml: 3,163; makefile: 5; sh: 5
file content (83 lines) | stat: -rw-r--r-- 2,165 bytes parent folder | download | duplicates (2)
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)