diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2014-07-28 20:01:23 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2014-07-30 19:48:41 +0200 |
commit | 5d11688d02e1f56722dce809cbe7ab5c49fea590 (patch) | |
tree | 58fb91bb31e6ebfdcf9c4d98cbec49fc7f829eb4 /tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp | |
parent | 5aacc43e64811751bae6545bfd302f4590212868 (diff) |
Fix QByteArray::to{Upper,Lower} when the array contains embedded nulls
[ChangeLog][QtCore][QByteArray] Fixed a bug that would cause QByteArray
to stop converting toUpper or toLower at the first embedded null
character.
Change-Id: Ia369037206617813d86a8f1489589243c82aa51b
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp')
-rw-r--r-- | tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp index 8fac232962..52e1850c87 100644 --- a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp +++ b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp @@ -151,6 +151,8 @@ private slots: #if defined(Q_COMPILER_LAMBDA) void literals(); #endif + void toUpperLower_data(); + void toUpperLower(); void macTypes(); @@ -1999,6 +2001,31 @@ void tst_QByteArray::literals() } #endif +void tst_QByteArray::toUpperLower_data() +{ + QTest::addColumn<QByteArray>("input"); + QTest::addColumn<QByteArray>("upper"); + QTest::addColumn<QByteArray>("lower"); + + QTest::newRow("empty") << QByteArray() << QByteArray() << QByteArray(); + QTest::newRow("ascii") << QByteArray("Hello World, this is a STRING") + << QByteArray("HELLO WORLD, THIS IS A STRING") + << QByteArray("hello world, this is a string"); + QTest::newRow("latin1") << QByteArray("R\311sum\351") + << QByteArray("R\311SUM\311") + << QByteArray("r\351sum\351"); + QTest::newRow("nul") << QByteArray("a\0B", 3) << QByteArray("A\0B", 3) << QByteArray("a\0b", 3); +} + +void tst_QByteArray::toUpperLower() +{ + QFETCH(QByteArray, input); + QFETCH(QByteArray, upper); + QFETCH(QByteArray, lower); + QCOMPARE(input.toUpper(), upper); + QCOMPARE(input.toLower(), lower); +} + void tst_QByteArray::macTypes() { #ifndef Q_OS_MAC |