summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/text/qbytearray
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2022-03-03 13:46:50 +0100
committerEdward Welbourne <edward.welbourne@qt.io>2022-03-18 01:22:54 +0100
commite10d613509fb606526fe1a0535dcceb81dbc7840 (patch)
tree20127f07720147be01d393541a68eac7593c8fdd /tests/auto/corelib/text/qbytearray
parente0206fe9d47bfbf18a0d4c2e5e780504305f72e7 (diff)
Add QByteArray::percentDecoded() as an instance method
Percent-decoding was previously only present as a static method taking a QBA parameter; it might as well be an instance method of that parameter. Change most QBA tests to use it rather the static method. [ChangeLog][QtCore][QByteArray] percentDecoded() is now available as an instance method of the byte array to be decoded, equivalent to the static QByteArray::fromPercentEncoding(). Change-Id: I982101c44bdac5cc4041e85598d52ac101d38fa1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib/text/qbytearray')
-rw-r--r--tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp b/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp
index 14102a9e63..78b6f4d506 100644
--- a/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp
+++ b/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp
@@ -1652,15 +1652,15 @@ void tst_QByteArray::toFromPercentEncoding()
QByteArray data = arr.toPercentEncoding();
QCOMPARE(data, QByteArray("Qt%20is%20great%21"));
- QCOMPARE(QByteArray::fromPercentEncoding(data), arr);
+ QCOMPARE(data.percentDecoded(), arr);
data = arr.toPercentEncoding("! ", "Qt");
QCOMPARE(data, QByteArray("%51%74 is grea%74!"));
- QCOMPARE(QByteArray::fromPercentEncoding(data), arr);
+ QCOMPARE(data.percentDecoded(), arr);
data = arr.toPercentEncoding(QByteArray(), "abcdefghijklmnopqrstuvwxyz", 'Q');
QCOMPARE(data, QByteArray("Q51Q74Q20Q69Q73Q20Q67Q72Q65Q61Q74Q21"));
- QCOMPARE(QByteArray::fromPercentEncoding(data, 'Q'), arr);
+ QCOMPARE(data.percentDecoded('Q'), arr);
// verify that to/from percent encoding preserves nullity
arr = "";
@@ -1676,16 +1676,16 @@ void tst_QByteArray::toFromPercentEncoding()
QVERIFY(arr.isNull());
QVERIFY(arr.toPercentEncoding().isEmpty());
QVERIFY(arr.toPercentEncoding().isNull());
- QVERIFY(QByteArray::fromPercentEncoding(QByteArray()).isEmpty());
- QVERIFY(QByteArray::fromPercentEncoding(QByteArray()).isNull());
+ QVERIFY(QByteArray().percentDecoded().isEmpty());
+ QVERIFY(QByteArray().percentDecoded().isNull());
// Verify that literal % in the string to be encoded does round-trip:
arr = "Qt%20is%20great%21";
data = arr.toPercentEncoding();
- QCOMPARE(QByteArray::fromPercentEncoding(data), arr);
+ QCOMPARE(data.percentDecoded(), arr);
arr = "87% of all statistics are made up!";
data = arr.toPercentEncoding();
- QCOMPARE(QByteArray::fromPercentEncoding(data), arr);
+ QCOMPARE(data.percentDecoded(), arr);
}
void tst_QByteArray::fromPercentEncoding_data()
@@ -1707,7 +1707,7 @@ void tst_QByteArray::fromPercentEncoding()
QFETCH(QByteArray, encodedString);
QFETCH(QByteArray, decodedString);
- QCOMPARE(QByteArray::fromPercentEncoding(encodedString), decodedString);
+ QCOMPARE(encodedString.percentDecoded(), decodedString);
}
void tst_QByteArray::toPercentEncoding_data()
@@ -1768,7 +1768,7 @@ void tst_QByteArray::pecentEncodingRoundTrip()
QByteArray encodedData = original.toPercentEncoding(excludeInEncoding, includeInEncoding);
QCOMPARE(encodedData, encoded);
- QCOMPARE(QByteArray::fromPercentEncoding(encodedData), original);
+ QCOMPARE(encodedData.percentDecoded(), original);
}
struct StringComparisonData