summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-04-14 19:29:40 +0200
committerMarc Mutz <marc.mutz@qt.io>2022-04-28 08:40:19 +0000
commite48b4d2b7c1d99ba8962a9c10a1508d16dc33fbf (patch)
tree520952b109a14e1bbddf51771b6ae6602ba3a614 /tests/auto
parent7a5d7e8440a1e4beec49b751d0ecacdf55aa45d5 (diff)
Implement support for '0b' prefix in toInt() etc
[ChangeLog][QtCore][QByteArray/QByteArrayView/QLatin1String/QString/QStringView] The string-to-integer conversion functions (toInt() etc) now support the 0b prefix for binary literals. That means that base = 0 will recognize 0b to mean base = 2 and an explicit base = 2 argument will make toInt() (etc) skip an optional 0b. [ChangeLog][QtCore][Important Behavior Changes] Due to the newly-introduced support for 0b (binary) prefixes in integer parsing, some strings that were previously rejected as invalid now parse as valid. E.g., Qt 6.3 with autodetected bases would have tried to parse "0b1" as an octal value and fail, whereas 6.4 will parse it as the binary literal and return 1. Fixes: QTBUG-85002 Change-Id: Id4eff72d63619080e5afece4d059b6ffd52f28c8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp5
1 files changed, 1 insertions, 4 deletions
diff --git a/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp b/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp
index c92cb0ad92..6a8f62d4b7 100644
--- a/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp
+++ b/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp
@@ -2654,14 +2654,13 @@ void tst_QStringApiSymmetry::toNumberWithBases_data()
const char prefix[3];
int base;
} bases[] = {
- { "", 2 }, // should be {"0b", 2}, but Qt lacks support for the 0b prefix (QTBUG-85002)
+ { "0b", 2 },
{ "0", 8 },
{ "", 10 },
{ "0x", 16 },
};
const auto check = [&](const char *input, qint64 n2, qint64 n8, qint64 n10, qint64 n16, bool result) {
-
for (const auto &e : bases) {
const QString data = QLatin1StringView(e.prefix) + QString::fromUtf8(input);
const auto row = [&](int base) {
@@ -2678,8 +2677,6 @@ void tst_QStringApiSymmetry::toNumberWithBases_data()
<< data << base << select(e.base /* NOT base! */) << result;
};
row(e.base); // explicit base
- if (e.base == 2)
- continue; // Qt doesn't know 0b (yet, QTBUG-85002), so nothing to auto-detect
row(0); // automatically detected base
}
};