summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools/qstring/tst_qstring.cpp
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/qstring/tst_qstring.cpp
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/qstring/tst_qstring.cpp')
-rw-r--r--tests/auto/corelib/tools/qstring/tst_qstring.cpp18
1 files changed, 2 insertions, 16 deletions
diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
index 3fb253c646..7e4f591f47 100644
--- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp
+++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
@@ -808,10 +808,7 @@ void tst_QString::constructorQByteArray()
QCOMPARE(str1.length(), expected.length());
QCOMPARE( str1, expected );
- QTextCodec::setCodecForCStrings( QTextCodec::codecForMib(4) ); // Latin 1
QString strBA(src);
- QTextCodec::setCodecForCStrings( 0 );
-
QCOMPARE( strBA, expected );
}
@@ -928,12 +925,7 @@ void tst_QString::sprintf()
QCOMPARE(a.sprintf("%-5.5s", "Hello" ),(QString)"Hello");
// Check utf8 conversion for %s
- QCOMPARE(a.sprintf("%s", "\303\266\303\244\303\274\303\226\303\204\303\234\303\270\303\246\303\245\303\230\303\206\303\205"), QString("\366\344\374\326\304\334\370\346\345\330\306\305"));
-
- // Check codecForCStrings is used to read non-modifier sequences in the format string
- QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
- QCOMPARE(a.sprintf("\303\251\303\250\303\240 %s", "\303\251\303\250\303\240"), QString("\303\251\303\250\303\240 \303\251\303\250\303\240"));
- QTextCodec::setCodecForCStrings(0);
+ QCOMPARE(a.sprintf("%s", "\303\266\303\244\303\274\303\226\303\204\303\234\303\270\303\246\303\245\303\230\303\206\303\205"), QString::fromLatin1("\366\344\374\326\304\334\370\346\345\330\306\305"));
int n1;
a.sprintf("%s%n%s", "hello", &n1, "goodbye");
@@ -1871,9 +1863,7 @@ void tst_QString::append_bytearray()
QFETCH( QString, str );
QFETCH( QByteArray, ba );
- QTextCodec::setCodecForCStrings( QTextCodec::codecForMib(4) ); // Latin 1
str.append( ba );
- QTextCodec::setCodecForCStrings( 0 );
QTEST( str, "res" );
}
@@ -1898,9 +1888,7 @@ void tst_QString::operator_pluseq_bytearray()
QFETCH( QString, str );
QFETCH( QByteArray, ba );
- QTextCodec::setCodecForCStrings( QTextCodec::codecForMib(4) ); // Latin 1
str += ba;
- QTextCodec::setCodecForCStrings( 0 );
QTEST( str, "res" );
}
@@ -1960,9 +1948,7 @@ void tst_QString::prepend_bytearray()
QFETCH( QString, str );
QFETCH( QByteArray, ba );
- QTextCodec::setCodecForCStrings( QTextCodec::codecForMib(4) ); // Latin 1
str.prepend( ba );
- QTextCodec::setCodecForCStrings( 0 );
QTEST( str, "res" );
}
@@ -3211,7 +3197,7 @@ void tst_QString::utf8()
QFETCH( QByteArray, utf8 );
QFETCH( QString, res );
- QCOMPARE( utf8, QByteArray(res.toUtf8()) );
+ QCOMPARE(res.toUtf8(), utf8);
}
void tst_QString::stringRef_utf8_data()