tst_qxmlstream: swap WHEN and THEN in readBack()

WHEN writing an invalid character, THEN we expect the writer to report
an error.

The old code had it the wrong way around. It checked that WHEN the
writer reports an error, THEN the character was invalid.

The formulations are equivalent, but the latter is mixing up cause and
effect, making it less clear what's being checked (QXmlStreamWriter,
not isValidSingleTextChar()), so swap.

Pick-to: 6.5 6.4 6.2
Change-Id: I703de9ddde98d9913977a913f671472930735900
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Mate Barany <mate.barany@qt.io>
This commit is contained in:
Marc Mutz 2022-12-12 10:25:01 +01:00
parent 7fa6670fa4
commit 7d0f08094a

View File

@ -1692,10 +1692,10 @@ void tst_QXmlStream::readBack() const
writer.writeEndDocument();
buffer.close();
if (writer.hasError()) {
QVERIFY2(!isValidSingleTextChar(c), QByteArray::number(c));
if (!isValidSingleTextChar(c)) {
QVERIFY2(writer.hasError(), QByteArray::number(c));
} else {
QVERIFY2(isValidSingleTextChar(c), QByteArray::number(c));
QVERIFY2(!writer.hasError(), QByteArray::number(c));
QVERIFY(buffer.open(QIODevice::ReadOnly));
QXmlStreamReader reader(&buffer);
do {