summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools/qstringbuilder
diff options
context:
space:
mode:
authorRobin Burchell <robin+qt@viroteck.net>2012-01-30 14:23:22 +0200
committerQt by Nokia <qt-info@nokia.com>2012-02-22 14:00:32 +0100
commit186692f81f2612c3cf3a4090cbf949f2fb1558f8 (patch)
treee4506e520a88a1c75086516a1edeb1ab2fb4d057 /tests/auto/corelib/tools/qstringbuilder
parent9d173c92183c30144e8bd4f115b2cd93c3da0d40 (diff)
Remove custom text codec for C strings.
This setting is extremely harmful, as code cannot know whether or not to expect it. It also made the behaviour of QString::fromAscii and ::toAscii unintuitive, and caused a lot of people to make mistakes with it. Change-Id: I2f429fa7ef93bd75bb93a7f64c56db15b7283388 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'tests/auto/corelib/tools/qstringbuilder')
-rw-r--r--tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp b/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp
index 95e24b22fb..afc16078b8 100644
--- a/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp
+++ b/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp
@@ -66,10 +66,8 @@
void runScenario()
{
- // set codec for C strings to 0, enforcing Latin1
- QTextCodec::setCodecForCStrings(0);
- QVERIFY(!QTextCodec::codecForCStrings());
-
+ // this code is latin1. TODO: replace it with the utf8 block below, once
+ // strings default to utf8.
QLatin1Literal l1literal(LITERAL);
QLatin1String l1string(LITERAL);
QString string(l1string);
@@ -130,7 +128,10 @@ void runScenario()
r = string P ba;
QCOMPARE(r, r2);
+#if 0
// now test with codec for C strings set
+ // TODO: to be re-enabled once strings default to utf8, in place of the
+ // latin1 code above.
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
QVERIFY(QTextCodec::codecForCStrings());
QCOMPARE(QTextCodec::codecForCStrings()->name(), QByteArray("UTF-8"));
@@ -153,6 +154,7 @@ void runScenario()
QCOMPARE(r, r3);
r = string P ba;
QCOMPARE(r, r3);
+#endif
ba = QByteArray(); // empty
r = ba P string;
@@ -212,9 +214,12 @@ void runScenario()
str += QLatin1String(LITERAL) P str;
QCOMPARE(str, QString::fromUtf8(UTF8_LITERAL LITERAL UTF8_LITERAL));
#ifndef QT_NO_CAST_FROM_ASCII
+#if 0
+ // TODO: this relies on strings defaulting to utf8, so disable this for now.
str = (QString::fromUtf8(UTF8_LITERAL) += QLatin1String(LITERAL) P UTF8_LITERAL);
QCOMPARE(str, QString::fromUtf8(UTF8_LITERAL LITERAL UTF8_LITERAL));
#endif
+#endif
}
//operator QByteArray +=
@@ -229,11 +234,14 @@ void runScenario()
ba2 += ba2 P withZero;
QCOMPARE(ba2, QByteArray(withZero + withZero + withZero));
#ifndef QT_NO_CAST_TO_ASCII
+#if 0
+ // TODO: this relies on strings defaulting to utf8, so disable this for now.
ba = UTF8_LITERAL;
ba2 = (ba += QLatin1String(LITERAL) + QString::fromUtf8(UTF8_LITERAL));
QCOMPARE(ba2, ba);
QCOMPARE(ba, QByteArray(UTF8_LITERAL LITERAL UTF8_LITERAL));
#endif
+#endif
}
}