summaryrefslogtreecommitdiffstats
path: root/tests/auto/qstringbuilder1
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2010-02-20 02:07:32 +0100
committerOlivier Goffart <olivier.goffart@nokia.com>2011-04-01 12:59:41 +0200
commit2365b2dfd57770875b6eefb165ec27f3bf65dd0c (patch)
tree50910e3040885973b26c52000619ca55baa930f8 /tests/auto/qstringbuilder1
parent9660d056a7040798c61f64cfb609181ead72f0c3 (diff)
QStringBuilder now support building QByteArray
This breaks source compatibility if one made its own QConcatenable as it nows require a Prefered type. And also sometimes if QT_USE_FAST_OPERATOR_PLUS was used, and the result of an addition between two QByteArray is used directly Reviewed-by: Denis
Diffstat (limited to 'tests/auto/qstringbuilder1')
-rw-r--r--tests/auto/qstringbuilder1/stringbuilder.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/auto/qstringbuilder1/stringbuilder.cpp b/tests/auto/qstringbuilder1/stringbuilder.cpp
index f3c0ea97dc..30d1ba3ee0 100644
--- a/tests/auto/qstringbuilder1/stringbuilder.cpp
+++ b/tests/auto/qstringbuilder1/stringbuilder.cpp
@@ -137,4 +137,34 @@ 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);
+
+ char mmh2[5];
+ strncpy(mmh2, mmh, 5);
+ QCOMPARE(QByteArray(ba P mmh2 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);
+ }
+
}