diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2013-10-10 19:43:22 -0700 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-12-13 09:30:04 +0100 |
commit | ee7536876cee007efef4b8d7e861721f88af1a19 (patch) | |
tree | 2f66aba902d93d3ff2d35cd20a45a0a39406418a /tests/auto/corelib/tools/qstring | |
parent | 8892e3d0fc8258975f27aa90bef741fb4254ce7e (diff) |
Add the UTF16-to-Latin1 in-place converter
This is only possible for two important reasons:
1) QString and QByteArray d pointers are both done with QArrayData and
that class does not care that the alignof(T) changes from 2 to 1,
so we can give the pointer from QString to QByteArray
(after adapting the allocated size, which is now double)
2) conversion from UTF16 to Latin1 always has fewer bytes (exactly half)
Change-Id: I17b2690c910f3de8db55156c6d6b5f55be06d827
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'tests/auto/corelib/tools/qstring')
-rw-r--r-- | tests/auto/corelib/tools/qstring/tst_qstring.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index 9a3aaebaaf..a0edc16718 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -3882,6 +3882,14 @@ void tst_QString::toLatin1Roundtrip() // and back: QCOMPARE(QString::fromLatin1(latin1, latin1.length()).length(), unicodedst.length()); QCOMPARE(QString::fromLatin1(latin1, latin1.length()), unicodedst); + + // try the rvalue version of toLatin1() + QString s = unicodesrc; + QCOMPARE(qMove(s).toLatin1(), latin1); + + // and verify that the moved-from object can still be used + s = "foo"; + s.clear(); } void tst_QString::stringRef_toLatin1Roundtrip_data() |