diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2022-03-23 19:11:13 +0100 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2022-03-23 19:34:30 +0100 |
commit | 1aea2d5b7e3b5f9ac7f8abdcdce57eeddf46e48d (patch) | |
tree | f35ffaec079a68ed380b8fb414307b06353277d4 /utils/rbutilqt/test/test-talkgenerator.cpp | |
parent | 822b16b1c6d7b406981ab7177b784479cd37e1a6 (diff) | |
download | rockbox-1aea2d5b7e3b5f9ac7f8abdcdce57eeddf46e48d.tar.gz rockbox-1aea2d5b7e3b5f9ac7f8abdcdce57eeddf46e48d.zip |
rbutil: Test for talkgenerator string correction.
Change-Id: I4c21dbbdae492938061883f1694f9c0f7b6b0fd9
Diffstat (limited to 'utils/rbutilqt/test/test-talkgenerator.cpp')
-rw-r--r-- | utils/rbutilqt/test/test-talkgenerator.cpp | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/utils/rbutilqt/test/test-talkgenerator.cpp b/utils/rbutilqt/test/test-talkgenerator.cpp new file mode 100644 index 0000000000..82649471da --- /dev/null +++ b/utils/rbutilqt/test/test-talkgenerator.cpp | |||
@@ -0,0 +1,83 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2022 Dominik Riebeling | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or | ||
12 | * modify it under the terms of the GNU General Public License | ||
13 | * as published by the Free Software Foundation; either version 2 | ||
14 | * of the License, or (at your option) any later version. | ||
15 | * | ||
16 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
17 | * KIND, either express or implied. | ||
18 | * | ||
19 | ****************************************************************************/ | ||
20 | |||
21 | #include <QtTest/QtTest> | ||
22 | #include <QObject> | ||
23 | #include "talkgenerator.h" | ||
24 | |||
25 | |||
26 | class TestTalkGenerator : public QObject | ||
27 | { | ||
28 | Q_OBJECT | ||
29 | private slots: | ||
30 | void testCorrectString(); | ||
31 | void testCorrectString_data(); | ||
32 | }; | ||
33 | |||
34 | |||
35 | |||
36 | void TestTalkGenerator::testCorrectString_data() | ||
37 | { | ||
38 | struct { | ||
39 | const char* language; | ||
40 | const char* from; | ||
41 | const char* to; | ||
42 | } const correctdata[] = | ||
43 | { | ||
44 | { "english", "dummy text", "dummy text" }, | ||
45 | { "deutsch", "alkaline", "alkalein" }, | ||
46 | { "deutsch", "Batterie Typ Alkaline", "Batterie Typ alkalein" }, | ||
47 | { "deutsch", "512 kilobytes frei", "512 kilobeits frei" }, | ||
48 | // AT&T engine only. | ||
49 | { "deutsch", "alphabet", "alphabet" }, | ||
50 | |||
51 | // espeak | ||
52 | {"svenska", "5 ampere", "5 ampär" }, | ||
53 | {"svenska", "bokmärken...", "bok-märken..." }, | ||
54 | }; | ||
55 | |||
56 | QTest::addColumn<QString>("language"); | ||
57 | QTest::addColumn<QString>("from"); | ||
58 | QTest::addColumn<QString>("to"); | ||
59 | for(size_t i = 0; i < sizeof(correctdata) / sizeof(correctdata[0]); i++) { | ||
60 | QTest::newRow(correctdata[i].from) | ||
61 | << correctdata[i].language << correctdata[i].from << correctdata[i].to; | ||
62 | } | ||
63 | } | ||
64 | |||
65 | void TestTalkGenerator::testCorrectString() | ||
66 | { | ||
67 | QFETCH(QString, language); | ||
68 | QFETCH(QString, from); | ||
69 | QFETCH(QString, to); | ||
70 | |||
71 | TalkGenerator t(this); | ||
72 | t.setLang(language); | ||
73 | QString corrected = t.correctString(from); | ||
74 | QCOMPARE(corrected, to); | ||
75 | } | ||
76 | |||
77 | |||
78 | QTEST_MAIN(TestTalkGenerator) | ||
79 | |||
80 | // this include is needed because we don't use a separate header file for the | ||
81 | // test class. It also needs to be at the end. | ||
82 | #include "test-talkgenerator.moc" | ||
83 | |||