tst_QPlainTextEdit/tst_QTextEdit: Do not output unprintable characters.

The test selectWordsFromStringsContainingSeparators() duplicated
in boths tests caused tab and Nbsp characters to be output to the
log, which upsets editors.
Use an array of ushort instead of a wasteful QStringList and
output the hex codes for the unprintable characters.

Change-Id: I08724268f376b4c0da492b4109570e44f7d4a3fb
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
This commit is contained in:
Friedemann Kleint 2016-05-31 13:21:58 +02:00
parent a9bef62ec2
commit ed08e3be34
2 changed files with 24 additions and 10 deletions

View File

@ -1184,12 +1184,19 @@ void tst_QPlainTextEdit::selectWordsFromStringsContainingSeparators_data()
QTest::addColumn<QString>("testString");
QTest::addColumn<QString>("selectedWord");
QStringList wordSeparators;
wordSeparators << "." << "," << "?" << "!" << ":" << ";" << "-" << "<" << ">" << "["
<< "]" << "(" << ")" << "{" << "}" << "=" << "\t"<< QString(QChar::Nbsp);
const ushort wordSeparators[] =
{'.', ',', '?', '!', ':', ';', '-', '<', '>', '[', ']', '(', ')', '{', '}',
'=', '\t', ushort(QChar::Nbsp)};
foreach (QString s, wordSeparators)
QTest::newRow(QString("separator: " + s).toLocal8Bit()) << QString("foo") + s + QString("bar") << QString("foo");
for (size_t i = 0, count = sizeof(wordSeparators) / sizeof(wordSeparators[0]); i < count; ++i) {
const ushort u = wordSeparators[i];
QByteArray rowName = QByteArrayLiteral("separator: ");
if (u >= 32 && u < 128)
rowName += char(u);
else
rowName += QByteArrayLiteral("0x") + QByteArray::number(u, 16);
QTest::newRow(rowName.constData()) << QString("foo") + QChar(u) + QString("bar") << QString("foo");
}
}
void tst_QPlainTextEdit::selectWordsFromStringsContainingSeparators()

View File

@ -1530,12 +1530,19 @@ void tst_QTextEdit::selectWordsFromStringsContainingSeparators_data()
QTest::addColumn<QString>("testString");
QTest::addColumn<QString>("selectedWord");
QStringList wordSeparators;
wordSeparators << "." << "," << "?" << "!" << ":" << ";" << "-" << "<" << ">" << "["
<< "]" << "(" << ")" << "{" << "}" << "=" << "\t"<< QString(QChar::Nbsp);
const ushort wordSeparators[] =
{'.', ',', '?', '!', ':', ';', '-', '<', '>', '[', ']', '(', ')', '{', '}',
'=', '\t', ushort(QChar::Nbsp)};
foreach (QString s, wordSeparators)
QTest::newRow(QString("separator: " + s).toLocal8Bit()) << QString("foo") + s + QString("bar") << QString("foo");
for (size_t i = 0, count = sizeof(wordSeparators) / sizeof(wordSeparators[0]); i < count; ++i) {
const ushort u = wordSeparators[i];
QByteArray rowName = QByteArrayLiteral("separator: ");
if (u >= 32 && u < 128)
rowName += char(u);
else
rowName += QByteArrayLiteral("0x") + QByteArray::number(u, 16);
QTest::newRow(rowName.constData()) << QString("foo") + QChar(u) + QString("bar") << QString("foo");
}
}
void tst_QTextEdit::selectWordsFromStringsContainingSeparators()