summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp
diff options
context:
space:
mode:
authorDavid Faure <david.faure@kdab.com>2013-09-02 10:26:21 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-17 00:45:03 +0100
commit2026e502596cf6d447caf9545ffed8d3f73fe597 (patch)
tree34a1b9181221c6da45d0f0edaeabe46ffccafbca /tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp
parentafe8e368721b6cac34d3b8de7689b53200f8c6fb (diff)
QCommandLineParser: add word-wrapping algorithm
Rather than breaking at column 79 precisely, break entire words, to improve readability. Change-Id: Ie30db00f0e6ed95cce87480c3b91804826c6076b Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
Diffstat (limited to 'tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp')
-rw-r--r--tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp49
1 files changed, 28 insertions, 21 deletions
diff --git a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp
index d8965dee5d..f37e192ad3 100644
--- a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp
+++ b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp
@@ -459,27 +459,40 @@ void tst_QCommandLineParser::testVersionOption()
#endif // !QT_NO_PROCESS
}
+static const char expectedOptionsHelp[] =
+ "Options:\n"
+ " -h, --help Displays this help.\n"
+ " -v, --version Displays version information.\n"
+ " --load <url> Load file from URL.\n"
+ " -o, --output <file> Set output file.\n"
+ " -D <key=value> Define macro.\n"
+ " -n, --no-implicit-includes Disable magic generation of implicit\n"
+ " #include-directives.\n"
+ " --newline This is an option with a rather long\n"
+ " description using explicit newline characters (but\n"
+ " testing automatic wrapping too). In addition,\n"
+ " here, we test breaking after a comma. Testing\n"
+ " -option. Long URL:\n"
+ " http://qt-project.org/wiki/How_to_create_a_library\n"
+ " _with_Qt_and_use_it_in_an_application\n"
+ " abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwx\n"
+ " yzabcdefghijklmnopqrstuvwxyz\n";
+
void tst_QCommandLineParser::testHelpOption_data()
{
QTest::addColumn<QCommandLineParser::SingleDashWordOptionMode>("parsingMode");
QTest::addColumn<QString>("expectedHelpOutput");
- QString expectedOutput =
+ QString expectedOutput = QString::fromLatin1(
"Usage: testhelper/qcommandlineparser_test_helper [options] parsingMode command\n"
"Test helper\n"
- "\n"
- "Options:\n"
- " -h, --help Displays this help.\n"
- " -v, --version Displays version information.\n"
- " --load <url> Load file from URL.\n"
- " -o, --output <file> Set output file.\n"
- " -D <key=value> Define macro.\n"
- " -n, --no-implicit-includes Disable automatic generation of implicit #include\n"
- " -directives.\n"
+ "\n")
+ + QString::fromLatin1(expectedOptionsHelp) +
+ QString::fromLatin1(
"\n"
"Arguments:\n"
" parsingMode The parsing mode to test.\n"
- " command The command to execute.\n";
+ " command The command to execute.\n");
#ifdef Q_OS_WIN
expectedOutput.replace(" -h, --help Displays this help.\n",
" -?, -h, --help Displays this help.\n");
@@ -510,6 +523,7 @@ void tst_QCommandLineParser::testHelpOption()
#ifdef Q_OS_WIN
output.replace(QStringLiteral("\r\n"), QStringLiteral("\n"));
#endif
+ QCOMPARE(output.split('\n'), expectedHelpOutput.split('\n')); // easier to debug than the next line, on failure
QCOMPARE(output, expectedHelpOutput);
process.start("testhelper/qcommandlineparser_test_helper", QStringList() << "0" << "resize" << "--help");
@@ -519,18 +533,11 @@ void tst_QCommandLineParser::testHelpOption()
#ifdef Q_OS_WIN
output.replace(QStringLiteral("\r\n"), QStringLiteral("\n"));
#endif
- QByteArray expectedResizeHelp =
+ QByteArray expectedResizeHelp = QByteArrayLiteral(
"Usage: testhelper/qcommandlineparser_test_helper [options] resize [resize_options]\n"
"Test helper\n"
- "\n"
- "Options:\n"
- " -h, --help Displays this help.\n"
- " -v, --version Displays version information.\n"
- " --load <url> Load file from URL.\n"
- " -o, --output <file> Set output file.\n"
- " -D <key=value> Define macro.\n"
- " -n, --no-implicit-includes Disable automatic generation of implicit #include\n"
- " -directives.\n"
+ "\n")
+ + expectedOptionsHelp +
" --size <size> New size.\n"
"\n"
"Arguments:\n"