From ee7536876cee007efef4b8d7e861721f88af1a19 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 10 Oct 2013 19:43:22 -0700 Subject: 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 Reviewed-by: Olivier Goffart --- tests/auto/corelib/tools/qstring/tst_qstring.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests/auto/corelib/tools/qstring') 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() -- cgit v1.2.3