/
test_mythmiscutil.cpp
63 lines (57 loc) · 2.26 KB
/
test_mythmiscutil.cpp
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
/*
* Class TestMiscUtil
*
* Copyright (c) David Hampton 2018
*
* 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) any later version.
*
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <iostream>
#include "test_mythmiscutil.h"
void TestMiscUtil::test_parse_cmdline_data(void)
{
QTest::addColumn<QString>("input");
QTest::addColumn<QStringList>("expectedOutput");
QTest::newRow("simple")
<< R"(This is a test string)"
<< QStringList({"This", "is", "a", "test", "string"});
QTest::newRow("simplequotes")
<< R"(cmd "whatever" "goes" here)"
<< QStringList({R"(cmd)",
R"("whatever")",
R"("goes")",
R"(here)"});
QTest::newRow("multiword")
<< R"(cmd "whatever" "multi-word argument" arg3)"
<< QStringList({R"(cmd)",
R"("whatever")",
R"("multi-word argument")",
R"(arg3)"});
QTest::newRow("mixedargs")
<< R"(cmd --arg1="whatever" --arg2="multi-word argument" --arg3)"
<< QStringList({R"(cmd)",
R"(--arg1="whatever")",
R"(--arg2="multi-word argument")",
R"(--arg3)"});
}
void TestMiscUtil::test_parse_cmdline(void)
{
QFETCH(QString, input);
QFETCH(QStringList, expectedOutput);
QStringList output = MythSplitCommandString(input);
// std::cerr << "Expected: " << qPrintable(expectedOutput.join("|")) << std::endl;
// std::cerr << "Actual: " << qPrintable(output.join("|")) << std::endl;
QCOMPARE(output, expectedOutput);
}
QTEST_APPLESS_MAIN(TestMiscUtil)