summaryrefslogtreecommitdiffstats
path: root/tests/auto/qstringref
diff options
context:
space:
mode:
authorOlivier Goffart <olivier.goffart@nokia.com>2010-06-02 12:43:53 (GMT)
committerOlivier Goffart <olivier.goffart@nokia.com>2010-06-02 12:43:53 (GMT)
commitd20d5611aec3eb2c4be1808250f8eed47e0ebf19 (patch)
tree455d6c4b30604f6ff792941f00d734ef7e394e29 /tests/auto/qstringref
parentbf6de2f79991bb66161960343f18fc1cae0aca41 (diff)
downloadQt-d20d5611aec3eb2c4be1808250f8eed47e0ebf19.zip
Qt-d20d5611aec3eb2c4be1808250f8eed47e0ebf19.tar.gz
Qt-d20d5611aec3eb2c4be1808250f8eed47e0ebf19.tar.bz2
Remove tst_QStringRef::localeAwareCompare
This new test breaks on embedded.
Diffstat (limited to 'tests/auto/qstringref')
-rw-r--r--tests/auto/qstringref/tst_qstringref.cpp176
1 files changed, 0 insertions, 176 deletions
diff --git a/tests/auto/qstringref/tst_qstringref.cpp b/tests/auto/qstringref/tst_qstringref.cpp
index 2d25efd..585e14e 100644
--- a/tests/auto/qstringref/tst_qstringref.cpp
+++ b/tests/auto/qstringref/tst_qstringref.cpp
@@ -81,8 +81,6 @@ private slots:
void compare_data();
void compare();
void operator_eqeq_nullstring();
- void localeAwareCompare_data();
- void localeAwareCompare();
};
static QStringRef emptyRef()
@@ -777,180 +775,6 @@ void tst_QStringRef::operator_eqeq_nullstring()
QVERIFY(QString("") == QString());
}
-void tst_QStringRef::localeAwareCompare_data()
-{
-#ifdef Q_OS_WIN
- QTest::addColumn<ulong>("locale");
-#else
- QTest::addColumn<QString>("locale");
-#endif
- QTest::addColumn<QString>("s1");
- QTest::addColumn<QString>("s2");
- QTest::addColumn<int>("result");
-
- /*
- The C locale performs pure byte comparisons for
- Latin-1-specific characters(I think). Compare with Swedish
- below.
- */
-#ifdef Q_OS_WIN // assume c locale to be english
- QTest::newRow("c1") << MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT) << QString("\xe5") << QString("\xe4") << 1;
- QTest::newRow("c2") << MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT) << QString("\xe4") << QString("\xf6") << -1;
- QTest::newRow("c3") << MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT) << QString("\xe5") << QString("\xf6") << -1;
-#else
- QTest::newRow("c1") << QString("C") << QString("\xe5") << QString("\xe4") << 1;
- QTest::newRow("c2") << QString("C") << QString("\xe4") << QString("\xf6") << -1;
- QTest::newRow("c3") << QString("C") << QString("\xe5") << QString("\xf6") << -1;
-#endif
-
- /*
- It's hard to test English, because it's treated differently
- on different platforms. For example, on Linux, it uses the
- iso14651_t1 template file, which happens to provide good
- defaults for Swedish. Mac OS X seems to do a pure bytewise
- comparison of Latin-1 values, although I'm not sure. So I
- just test digits to make sure that it's not totally broken.
- */
-#ifdef Q_OS_WIN
- QTest::newRow("english1") << MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT) << QString("5") << QString("4") << 1;
- QTest::newRow("english2") << MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT) << QString("4") << QString("6") << -1;
- QTest::newRow("english3") << MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT) << QString("5") << QString("6") << -1;
-#else
- QTest::newRow("english1") << QString("en_US") << QString("5") << QString("4") << 1;
- QTest::newRow("english2") << QString("en_US") << QString("4") << QString("6") << -1;
- QTest::newRow("english3") << QString("en_US") << QString("5") << QString("6") << -1;
-#endif
- /*
- In Swedish, a with ring above(E5) comes before a with
- diaresis(E4), which comes before o diaresis(F6), which
- all come after z.
- */
-#ifdef Q_OS_MAC
- QTest::newRow("swedish1") << QString("sv_SE.ISO8859-1") << QString("\xe5") << QString("\xe4") << -1;
- QTest::newRow("swedish2") << QString("sv_SE.ISO8859-1") << QString("\xe4") << QString("\xf6") << -1;
- QTest::newRow("swedish3") << QString("sv_SE.ISO8859-1") << QString("\xe5") << QString("\xf6") << -1;
- QTest::newRow("swedish4") << QString("sv_SE.ISO8859-1") << QString("z") << QString("\xe5") << -1;
-#elif defined(Q_OS_WIN)
- QTest::newRow("swedish1") << MAKELCID(MAKELANGID(LANG_SWEDISH, SUBLANG_SWEDISH), SORT_DEFAULT) << QString("\xe5") << QString("\xe4") << -1;
- QTest::newRow("swedish2") << MAKELCID(MAKELANGID(LANG_SWEDISH, SUBLANG_SWEDISH), SORT_DEFAULT) << QString("\xe4") << QString("\xf6") << -1;
- QTest::newRow("swedish3") << MAKELCID(MAKELANGID(LANG_SWEDISH, SUBLANG_SWEDISH), SORT_DEFAULT) << QString("\xe5") << QString("\xf6") << -1;
- QTest::newRow("swedish4") << MAKELCID(MAKELANGID(LANG_SWEDISH, SUBLANG_SWEDISH), SORT_DEFAULT) << QString("z") << QString("\xe5") << -1;
-#else
- QTest::newRow("swedish1") << QString("sv_SE") << QString("\xe5") << QString("\xe4") << -1;
- QTest::newRow("swedish2") << QString("sv_SE") << QString("\xe4") << QString("\xf6") << -1;
- QTest::newRow("swedish3") << QString("sv_SE") << QString("\xe5") << QString("\xf6") << -1;
- QTest::newRow("swedish4") << QString("sv_SE") << QString("z") << QString("\xe5") << -1;
-#endif
-
-#if 0
- /*
- In Norwegian, ae(E6) comes before o with stroke(D8), which
- comes before a with ring above(E5).
- */
- QTest::newRow("norwegian1") << QString("no_NO") << QString("\xe6") << QString("\xd8") << -1;
- QTest::newRow("norwegian2") << QString("no_NO") << QString("\xd8") << QString("\xe5") << -1;
- QTest::newRow("norwegian3") << QString("no_NO") << QString("\xe6") << QString("\xe5") << -1;
-#endif
-
- /*
- In German, z comes *after* a with diaresis(E4),
- which comes before o diaresis(F6).
- */
-#ifdef Q_OS_MAC
- QTest::newRow("german1") << QString("de_DE.ISO8859-1") << QString("z") << QString("\xe4") << 1;
- QTest::newRow("german2") << QString("de_DE.ISO8859-1") << QString("\xe4") << QString("\xf6") << -1;
- QTest::newRow("german3") << QString("de_DE.ISO8859-1") << QString("z") << QString("\xf6") << 1;
-#elif defined(Q_OS_WIN)
- QTest::newRow("german1") << MAKELCID(MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN), SORT_DEFAULT) << QString("z") << QString("\xe4") << 1;
- QTest::newRow("german2") << MAKELCID(MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN), SORT_DEFAULT) << QString("\xe4") << QString("\xf6") << -1;
- QTest::newRow("german3") << MAKELCID(MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN), SORT_DEFAULT) << QString("z") << QString("\xf6") << 1;
-#else
- QTest::newRow("german1") << QString("de_DE") << QString("z") << QString("\xe4") << 1;
- QTest::newRow("german2") << QString("de_DE") << QString("\xe4") << QString("\xf6") << -1;
- QTest::newRow("german3") << QString("de_DE") << QString("z") << QString("\xf6") << 1;
-#endif
-}
-
-void tst_QStringRef::localeAwareCompare()
-{
-#ifdef Q_OS_WIN
-# ifndef Q_OS_WINCE
- QSKIP("On others than Win CE, we cannot set the system or user locale.", SkipAll);
-# endif
- QFETCH(ulong, locale);
-#else
- QFETCH(QString, locale);
-#endif
- QFETCH(QString, s1);
- QFETCH(QString, s2);
-
- const QString padded1 = QString::fromLatin1(" %1 ").arg(s1);
- const QString padded2 = QString::fromLatin1(" %2 ").arg(s2);
- const QStringRef ref1 = padded1.midRef(1, s1.size());
- const QStringRef ref2 = padded2.midRef(1, s2.size());
-
- QFETCH(int, result);
-
-
-#ifdef Q_OS_WIN
-# if defined(Q_OS_WINCE)
- DWORD oldLcid = GetUserDefaultLCID();
- SetUserDefaultLCID(locale);
-
- QCOMPARE(locale, GetUserDefaultLCID());
-# else
- DWORD oldLcid = GetThreadLocale();
- SetThreadLocale(locale);
-
- QCOMPARE(locale, GetThreadLocale());
-# endif
-
-#elif defined(Q_WS_MAC)
- QSKIP("Setting the locale is not supported on OS X(you can set the C locale, but that won't affect CFStringCompare which is used to compare strings)", SkipAll);
-#else
- if (!locale.isEmpty()) {
- const char *newLocale = setlocale(LC_ALL, locale.toLatin1());
- if (!newLocale) {
- setlocale(LC_ALL, "");
- QSKIP("Please install the proper locale on this machine to test properly", SkipSingle);
- return;
- }
- }
-#endif
-
- int testres = QStringRef::localeAwareCompare(ref1, ref2);
- if (result < 0) {
- QVERIFY(testres < 0);
- } else if (result > 0) {
- QVERIFY(testres > 0);
- } else {
- QVERIFY(testres == 0);
- }
-
-
- testres = QStringRef::localeAwareCompare(ref2, ref1);
- if (result > 0) {
- QVERIFY(testres < 0);
- } else if (result < 0) {
- QVERIFY(testres > 0);
- } else {
- QVERIFY(testres == 0);
- }
-
-#ifdef Q_OS_WIN
-# if defined(Q_OS_WINCE)
- SetUserDefaultLCID(oldLcid);
-# else
- SetThreadLocale(oldLcid);
-# endif
-
-#else
- if (!locale.isEmpty())
- setlocale(LC_ALL, "");
-#endif
-}
-
-
static inline int sign(int x)
{
return x == 0 ? 0 : (x < 0 ? -1 : 1);