summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2011-08-19 12:17:06 +0200
committerQt by Nokia <qt-info@nokia.com>2011-08-31 13:12:43 +0200
commit3526560d60ef82cd04e4fdf2e0ab751c0aca9731 (patch)
treea8b6ca6427ef7f331a5508a90dfc335c050d0044 /tests
parent46ff3a4b1f0ee9fc87bafe2679f322aab689889c (diff)
Add QLocale::toUpper/Lower
The toUpper/Lower() methods in QString should not be locale dependent, as this can lead to rather hard to find bugs in at least a turkish locale. Rather have explicit, locale dependend case conversions available in QLocale. Reviewed-by: Denis Dzyubenko (cherry picked from commit da0e1e101bb4c44c25b6523357fa81ad1b2d6539) Change-Id: I1cc3f341bef17ad573a736dc94c9c5d514ace54e Reviewed-on: http://codereview.qt.nokia.com/3259 Reviewed-by: Lars Knoll <lars.knoll@nokia.com> Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qstring/tst_qstring.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/tests/auto/qstring/tst_qstring.cpp b/tests/auto/qstring/tst_qstring.cpp
index f7a725c164..cf68bda31f 100644
--- a/tests/auto/qstring/tst_qstring.cpp
+++ b/tests/auto/qstring/tst_qstring.cpp
@@ -5086,24 +5086,28 @@ void tst_QString::toUpperLower_icu()
QLocale::setDefault(QLocale(QLocale::Turkish, QLocale::Turkey));
+ QCOMPARE(s.toUpper(), QString::fromLatin1("I"));
+ QCOMPARE(s.toLower(), QString::fromLatin1("i"));
+
// turkish locale has a capital I with a dot (U+0130, utf8 c4b0)
+ QLocale l;
- QCOMPARE(s.toUpper(), QString::fromUtf8("\xc4\xb0"));
- QCOMPARE(QString::fromUtf8("\xc4\xb0").toLower(), s);
+ QCOMPARE(l.toUpper(s), QString::fromUtf8("\xc4\xb0"));
+ QCOMPARE(l.toLower(QString::fromUtf8("\xc4\xb0")), s);
// nothing should happen here
- QCOMPARE(s.toLower(), s);
- QCOMPARE(QString::fromLatin1("I").toUpper(), QString::fromLatin1("I"));
+ QCOMPARE(l.toLower(s), s);
+ QCOMPARE(l.toUpper(QString::fromLatin1("I")), QString::fromLatin1("I"));
// U+0131, utf8 c4b1 is the lower-case i without a dot
QString sup = QString::fromUtf8("\xc4\xb1");
- QCOMPARE(sup.toUpper(), QString::fromLatin1("I"));
- QCOMPARE(QString::fromLatin1("I").toLower(), sup);
+ QCOMPARE(l.toUpper(sup), QString::fromLatin1("I"));
+ QCOMPARE(l.toLower(QString::fromLatin1("I")), sup);
// nothing should happen here
- QCOMPARE(sup.toLower(), sup);
- QCOMPARE(QString::fromLatin1("i").toLower(), QString::fromLatin1("i"));
+ QCOMPARE(l.toLower(sup), sup);
+ QCOMPARE(l.toLower(QString::fromLatin1("i")), QString::fromLatin1("i"));
// the cleanup function will restore the default locale
}