diff options
Diffstat (limited to 'tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp')
-rw-r--r-- | tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp | 19 |
1 files changed, 19 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..8fac232962 100644 --- a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp +++ b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp @@ -153,6 +153,8 @@ private slots: #endif void macTypes(); + + void stdString(); }; static const struct StaticByteArrays { @@ -2007,6 +2009,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) |