summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp')
-rw-r--r--tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp
index cdcbd19ae8..52e1850c87 100644
--- a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp
+++ b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp
@@ -151,8 +151,12 @@ private slots:
#if defined(Q_COMPILER_LAMBDA)
void literals();
#endif
+ void toUpperLower_data();
+ void toUpperLower();
void macTypes();
+
+ void stdString();
};
static const struct StaticByteArrays {
@@ -1997,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
@@ -2007,6 +2036,23 @@ void tst_QByteArray::macTypes()
#endif
}
+void tst_QByteArray::stdString()
+{
+ std::string stdstr( "QByteArray" );
+
+ const QByteArray stlqt = QByteArray::fromStdString(stdstr);
+ QCOMPARE(stlqt.length(), int(stdstr.length()));
+ QCOMPARE(stlqt.data(), stdstr.c_str());
+ QCOMPARE(stlqt.toStdString(), stdstr);
+
+ std::string utf8str( "Nøt æscii" );
+ const QByteArray u8 = QByteArray::fromStdString(utf8str);
+ const QByteArray l1 = QString::fromUtf8(u8).toLatin1();
+ std::string l1str = l1.toStdString();
+ QVERIFY(l1str.length() < utf8str.length());
+}
+
+
const char globalChar = '1';
QTEST_MAIN(tst_QByteArray)