diff options
author | Marc Mutz <marc.mutz@qt.io> | 2023-06-02 16:22:37 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2023-06-09 11:50:18 +0000 |
commit | 05e388013098887eb66090b8f145ef92d60657db (patch) | |
tree | cb80d97b9d97c903834eff397f45e773110d7d25 /tests/auto/corelib/text/qstring/tst_qstring.cpp | |
parent | fe5d9340b13cb1dc7fd185b725d7c1c018da3bcb (diff) |
QString: add STL-style assign() [3/4]: (it,it) overload for char32_t
This no longer is range-length preserving now, so adapt the
documentation.
For the non-contiguous iterator case, it's actually ok to always
resize(0) and then append(), because, unlike for QList and QVLA, the
resize(0) doesn't actually iterate the container to destroy
elements. It just sets some members and conveniently detach()es for
us.
The char8_t case is even more complicated, since we can, atm, not
include qstringconverter.h into qstring.h, yet qstringconverter is
required for stateful UTF-8 decoding in the input_iterator case. So
that's postponed to yet another patch, and maybe won't make it into
6.6. But I feel it's important to have at least one
non-length-preserving version of assign(it, it) in before release lest
users come to rely on this documented (and de-facto) feature of the
the step-2 assign().
Fixes: QTBUG-106198
Pick-to: 6.6
Change-Id: Id458776e91b16fb2c80196e339cb817adee5d6d9
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Diffstat (limited to 'tests/auto/corelib/text/qstring/tst_qstring.cpp')
-rw-r--r-- | tests/auto/corelib/text/qstring/tst_qstring.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/auto/corelib/text/qstring/tst_qstring.cpp b/tests/auto/corelib/text/qstring/tst_qstring.cpp index f3d2594e34..eaf35c969e 100644 --- a/tests/auto/corelib/text/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/text/qstring/tst_qstring.cpp @@ -3442,6 +3442,14 @@ void tst_QString::assign() str.assign(c16str.begin(), c16str.end()); QCOMPARE(str, c16); + const char32_t c32[] = U"٩(⁎❛ᴗ❛⁎)۶ 🤷"; + str.assign(std::begin(c32), std::end(c32) - 1); + QCOMPARE(str, c16); + + std::u32string c32str(c32); + str.assign(c32str.begin(), c32str.end()); + QCOMPARE(str, c16); + QVarLengthArray<QLatin1Char, 5> l1ch = {'F'_L1, 'G'_L1, 'H'_L1, 'I'_L1, 'J'_L1}; str.assign(l1ch.begin(), l1ch.end()); QCOMPARE(str, u"FGHIJ"); |