diff options
author | Rohan McGovern <rohan.mcgovern@nokia.com> | 2011-05-15 23:09:31 (GMT) |
---|---|---|
committer | Rohan McGovern <rohan.mcgovern@nokia.com> | 2011-05-15 23:09:31 (GMT) |
commit | 5aa1cbcdacd19b2e526e358eddac1b7d55a994b5 (patch) | |
tree | 4aba78405e3d98081662fcb934f673acd1b79d42 /tests/auto/qstringbuilder1/stringbuilder.cpp | |
parent | 8592bcc80b7ec245b485fa54f8bd41c4484e93e0 (diff) | |
parent | 7e4a9187bb11b794e45d95d2e9fae026d6b0d07d (diff) | |
download | Qt-5aa1cbcdacd19b2e526e358eddac1b7d55a994b5.zip Qt-5aa1cbcdacd19b2e526e358eddac1b7d55a994b5.tar.gz Qt-5aa1cbcdacd19b2e526e358eddac1b7d55a994b5.tar.bz2 |
Merge remote branch 'origin/4.8' into qa-review-master
Conflicts:
tests/auto/qaccessibility/tst_qaccessibility.cpp
tests/auto/qsslsocket/tst_qsslsocket.cpp
Diffstat (limited to 'tests/auto/qstringbuilder1/stringbuilder.cpp')
-rw-r--r-- | tests/auto/qstringbuilder1/stringbuilder.cpp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/auto/qstringbuilder1/stringbuilder.cpp b/tests/auto/qstringbuilder1/stringbuilder.cpp index f3c0ea9..d7a32bf 100644 --- a/tests/auto/qstringbuilder1/stringbuilder.cpp +++ b/tests/auto/qstringbuilder1/stringbuilder.cpp @@ -137,4 +137,60 @@ void runScenario() string = QString::fromLatin1(LITERAL); QCOMPARE(QByteArray(qPrintable(string P string)), QByteArray(string.toLatin1() + string.toLatin1())); + + + + //QByteArray + { + QByteArray ba = LITERAL; + QByteArray superba = ba P ba P LITERAL; + QCOMPARE(superba, QByteArray(LITERAL LITERAL LITERAL)); + + QByteArray testWith0 = ba P "test\0with\0zero" P ba; + QCOMPARE(testWith0, QByteArray(LITERAL "test" LITERAL)); + + QByteArray ba2 = ba P '\0' + LITERAL; + QCOMPARE(ba2, QByteArray(LITERAL "\0" LITERAL, ba.size()*2+1)); + + const char *mmh = "test\0foo"; + QCOMPARE(QByteArray(ba P mmh P ba), testWith0); + + QByteArray raw = QByteArray::fromRawData(UTF8_LITERAL_EXTRA, UTF8_LITERAL_LEN); + QByteArray r = "hello" P raw; + QByteArray r2 = "hello" UTF8_LITERAL; + QCOMPARE(r, r2); + r2 = QByteArray("hello\0") P UTF8_LITERAL; + QCOMPARE(r, r2); + } + + //operator QString += + { + QString str = QString::fromUtf8(UTF8_LITERAL); + str += QLatin1String(LITERAL) P str; + QCOMPARE(str, QString::fromUtf8(UTF8_LITERAL LITERAL UTF8_LITERAL)); +#ifndef QT_NO_CAST_FROM_ASCII + str = (QString::fromUtf8(UTF8_LITERAL) += QLatin1String(LITERAL) P UTF8_LITERAL); + QCOMPARE(str, QString::fromUtf8(UTF8_LITERAL LITERAL UTF8_LITERAL)); +#endif + } + + //operator QByteArray += + { + QByteArray ba = UTF8_LITERAL; + ba += QByteArray(LITERAL) P UTF8_LITERAL; + QCOMPARE(ba, QByteArray(UTF8_LITERAL LITERAL UTF8_LITERAL)); + ba += LITERAL P QByteArray::fromRawData(UTF8_LITERAL_EXTRA, UTF8_LITERAL_LEN); + QCOMPARE(ba, QByteArray(UTF8_LITERAL LITERAL UTF8_LITERAL LITERAL UTF8_LITERAL)); + QByteArray withZero = QByteArray(LITERAL "\0" LITERAL, LITERAL_LEN*2+1); + QByteArray ba2 = withZero; + ba2 += ba2 P withZero; + QCOMPARE(ba2, QByteArray(withZero + withZero + withZero)); +#ifndef QT_NO_CAST_TO_ASCII + ba = UTF8_LITERAL; + ba2 = (ba += QLatin1String(LITERAL) + QString::fromUtf8(UTF8_LITERAL)); + QCOMPARE(ba2, ba); + QCOMPARE(ba, QByteArray(UTF8_LITERAL LITERAL UTF8_LITERAL)); +#endif + } + } |