diff options
author | Harald Fernengel <harald.fernengel@nokia.com> | 2009-11-04 13:10:47 (GMT) |
---|---|---|
committer | Harald Fernengel <harald.fernengel@nokia.com> | 2009-11-04 15:09:18 (GMT) |
commit | 90b26c211bca82e252dcd31ffa1ef6834bbb6060 (patch) | |
tree | 8097a2649f3b9832e2d6ec80a89f7bc4a9e9d3e8 /tests/auto/qstringbuilder1/stringbuilder.cpp | |
parent | 375bbf981fb4fc9a910aa078f6b7caf19c255ae8 (diff) | |
download | Qt-90b26c211bca82e252dcd31ffa1ef6834bbb6060.zip Qt-90b26c211bca82e252dcd31ffa1ef6834bbb6060.tar.gz Qt-90b26c211bca82e252dcd31ffa1ef6834bbb6060.tar.bz2 |
Make QStringBuilder respect codecForCStrings
Now, it's a real drop-in replacement, with no known feature regressions
:)
Reviewed-By: hjk
Diffstat (limited to 'tests/auto/qstringbuilder1/stringbuilder.cpp')
-rw-r--r-- | tests/auto/qstringbuilder1/stringbuilder.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/auto/qstringbuilder1/stringbuilder.cpp b/tests/auto/qstringbuilder1/stringbuilder.cpp index f35d4d2..9dc467e 100644 --- a/tests/auto/qstringbuilder1/stringbuilder.cpp +++ b/tests/auto/qstringbuilder1/stringbuilder.cpp @@ -41,8 +41,15 @@ #define LITERAL "some literal" +// "some literal", but replacing all vocals by their umlauted UTF-8 string :) +#define UTF8_LITERAL "s\xc3\xb6m\xc3\xab l\xc3\xaft\xc3\xabr\xc3\xa4l" + void runScenario() { + // set codec for C strings to 0, enforcing Latin1 + QTextCodec::setCodecForCStrings(0); + QVERIFY(!QTextCodec::codecForCStrings()); + QLatin1Literal l1literal(LITERAL); QLatin1String l1string(LITERAL); QString string(l1string); @@ -75,5 +82,24 @@ void runScenario() QCOMPARE(r, r2); r = string P ba; QCOMPARE(r, r2); + + // now test with codec for C strings set + QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); + QVERIFY(QTextCodec::codecForCStrings()); + QCOMPARE(QTextCodec::codecForCStrings()->name(), QByteArray("UTF-8")); + + string = QString::fromUtf8(UTF8_LITERAL); + r2 = QString::fromUtf8(UTF8_LITERAL UTF8_LITERAL); + ba = UTF8_LITERAL; + + r = string P UTF8_LITERAL; + QCOMPARE(r.size(), r2.size()); + QCOMPARE(r, r2); + r = UTF8_LITERAL P string; + QCOMPARE(r, r2); + r = ba P string; + QCOMPARE(r, r2); + r = string P ba; + QCOMPARE(r, r2); #endif } |