From 4793356ce769b301ff39ce304b731cffc2ad2741 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 21 May 2012 18:27:26 +0200 Subject: [PATCH] Fix the idempotent recoding tests in tst_QUrlInternal This was trying all the possibilities by brute force, but it turns out that some combinations are not valid so they should not be tested. What's more, it was using old values of the flags, so this was actually testing nothing. Change-Id: I6c2f5230d240fc23418df2d3a1ca905dbc47dd10 Reviewed-by: Lars Knoll Reviewed-by: David Faure Reviewed-by: Shane Kearns --- .../corelib/io/qurlinternal/tst_qurlinternal.cpp | 31 +++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp b/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp index 3ac2b46..43266f1 100644 --- a/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp +++ b/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp @@ -834,9 +834,34 @@ void tst_QUrlInternal::encodingRecode_data() QTest::addColumn("expected"); // -- idempotent tests -- - for (int i = 0; i < 0x10; ++i) { - QByteArray code = QByteArray::number(i, 16); - F mode = QUrl::ComponentFormattingOption(i << 12); + static int modes[] = { QUrl::PrettyDecoded, + QUrl::EncodeSpaces, + QUrl::EncodeSpaces | QUrl::EncodeUnicode, + QUrl::EncodeSpaces | QUrl::EncodeUnicode | QUrl::EncodeDelimiters, + QUrl::EncodeSpaces | QUrl::EncodeUnicode | QUrl::EncodeDelimiters | QUrl::EncodeReserved, + QUrl::EncodeSpaces | QUrl::EncodeUnicode | QUrl::EncodeDelimiters | QUrl::DecodeReserved, + QUrl::EncodeSpaces | QUrl::EncodeUnicode | QUrl::EncodeReserved, + QUrl::EncodeSpaces | QUrl::EncodeUnicode | QUrl::DecodeReserved, + QUrl::EncodeSpaces | QUrl::EncodeDelimiters, + QUrl::EncodeSpaces | QUrl::EncodeDelimiters | QUrl::EncodeReserved, + QUrl::EncodeSpaces | QUrl::EncodeDelimiters | QUrl::DecodeReserved, + QUrl::EncodeSpaces | QUrl::EncodeReserved, + QUrl::EncodeSpaces | QUrl::DecodeReserved, + + QUrl::EncodeUnicode, + QUrl::EncodeUnicode | QUrl::EncodeDelimiters, + QUrl::EncodeUnicode | QUrl::EncodeDelimiters | QUrl::EncodeReserved, + QUrl::EncodeUnicode | QUrl::EncodeDelimiters | QUrl::DecodeReserved, + QUrl::EncodeUnicode | QUrl::EncodeReserved, + + QUrl::EncodeDelimiters, + QUrl::EncodeDelimiters | QUrl::EncodeReserved, + QUrl::EncodeDelimiters | QUrl::DecodeReserved, + QUrl::EncodeReserved, + QUrl::DecodeReserved }; + for (uint i = 0; i < sizeof(modes)/sizeof(modes[0]); ++i) { + QByteArray code = QByteArray::number(modes[i], 16); + F mode = QUrl::ComponentFormattingOption(modes[i]); QTest::newRow("null-0x" + code) << QString() << mode << QString(); QTest::newRow("empty-0x" + code) << "" << mode << ""; -- 2.7.4