From 84984cfce2e85690fed1c72e5363ce00657cc753 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 3 Mar 2022 14:22:00 +0100 Subject: [PATCH] Add some %-encoding round-trip tests that use % in the plain-text MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This was not previously tested. Change-Id: Icd287b519f6bc5d450f4490990ac78b0d06774f6 Reviewed-by: MÃ¥rten Nordheim Reviewed-by: Thiago Macieira --- tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp b/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp index 91611dd0b0..14102a9e63 100644 --- a/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp +++ b/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2021 The Qt Company Ltd. +** Copyright (C) 2022 The Qt Company Ltd. ** Copyright (C) 2016 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** @@ -1678,6 +1678,14 @@ void tst_QByteArray::toFromPercentEncoding() QVERIFY(arr.toPercentEncoding().isNull()); QVERIFY(QByteArray::fromPercentEncoding(QByteArray()).isEmpty()); QVERIFY(QByteArray::fromPercentEncoding(QByteArray()).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); + arr = "87% of all statistics are made up!"; + data = arr.toPercentEncoding(); + QCOMPARE(QByteArray::fromPercentEncoding(data), arr); } void tst_QByteArray::fromPercentEncoding_data()