Skip to content

Commit

Permalink
Move a test for feature ICU from .pro to .cpp
Browse files Browse the repository at this point in the history
Test QT_CONFIG(icu) in the code instead of testing qtConfig(icu) in
the profile and setting an extra define just to shadow what's already
defined. Also remove the matching define from qcollator.pro, whose
test code didn't use it.

Noticed while reviewing the conversions to CMake.

Change-Id: I19d3b1026b2a8f50ec424c450614e721500fd38a
Reviewed-by: Qt CI Bot <[email protected]>
Reviewed-by: Frederik Gladhorn <[email protected]>
  • Loading branch information
ediosyncratic committed Oct 25, 2019
1 parent 6acab25 commit 946c701
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
1 change: 0 additions & 1 deletion tests/auto/corelib/text/qcollator/qcollator.pro
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ TARGET = tst_qcollator
QT = core-private testlib
SOURCES = tst_qcollator.cpp
DEFINES += QT_NO_CAST_TO_ASCII
qtConfig(icu): DEFINES += QT_USE_ICU
1 change: 0 additions & 1 deletion tests/auto/corelib/text/qstring/qstring.pro
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ TARGET = tst_qstring
QT = core-private testlib
SOURCES = tst_qstring.cpp
DEFINES += QT_NO_CAST_TO_ASCII
qtConfig(icu): DEFINES += QT_USE_ICU
qtConfig(c++11): CONFIG += c++11
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0

Expand Down
21 changes: 11 additions & 10 deletions tests/auto/corelib/text/qstring/tst_qstring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
# undef QT_ASCII_CAST_WARNINGS
#endif

#include <private/qglobal_p.h> // for the icu feature test
#include <QtTest/QtTest>
#include <qregexp.h>
#include <qregularexpression.h>
Expand Down Expand Up @@ -577,7 +578,7 @@ private slots:
void repeated_data() const;
void compareRef();
void arg_locale();
#ifdef QT_USE_ICU
#if QT_CONFIG(icu)
void toUpperLower_icu();
#endif
#if !defined(QT_NO_UNICODE_LITERAL)
Expand Down Expand Up @@ -2235,7 +2236,7 @@ void tst_QString::toUpper()
upper += QChar(QChar::highSurrogate(0x10428));
QCOMPARE(lower.toUpper(), upper);

#ifdef QT_USE_ICU
#if QT_CONFIG(icu)
// test doesn't work with ICU support, since QChar is unaware of any locale
QEXPECT_FAIL("", "test doesn't work with ICU support, since QChar is unaware of any locale", Continue);
QVERIFY(false);
Expand All @@ -2247,7 +2248,7 @@ void tst_QString::toUpper()
if (upper.length() == 1)
QVERIFY(upper == QString(1, QChar(i).toUpper()));
}
#endif
#endif // icu
}

void tst_QString::toLower()
Expand Down Expand Up @@ -2295,7 +2296,7 @@ void tst_QString::toLower()
upper += QChar(QChar::highSurrogate(0x10400));
QCOMPARE( upper.toLower(), lower);

#ifdef QT_USE_ICU
#if QT_CONFIG(icu)
// test doesn't work with ICU support, since QChar is unaware of any locale
QEXPECT_FAIL("", "test doesn't work with ICU support, since QChar is unaware of any locale", Continue);
QVERIFY(false);
Expand All @@ -2307,7 +2308,7 @@ void tst_QString::toLower()
if (lower.length() == 1)
QVERIFY(str.toLower() == QString(1, QChar(i).toLower()));
}
#endif
#endif // icu
}

void tst_QString::isUpper()
Expand Down Expand Up @@ -5623,18 +5624,18 @@ void tst_QString::localeAwareCompare()
QStringRef r2(&s2, 0, s2.length());

if (!locale.isEmpty()) {
#if defined (Q_OS_DARWIN) || defined(QT_USE_ICU)
#if defined (Q_OS_DARWIN) || QT_CONFIG(icu)
QSKIP("Setting the locale is not supported on OS X or ICU (you can set the C locale, but that won't affect localeAwareCompare)");
#else
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");
}
#endif
#endif // Darwin || icu
}

#ifdef QT_USE_ICU
#if QT_CONFIG(icu)
// ### for c1, ICU disagrees with libc on how to compare
QEXPECT_FAIL("c1", "ICU disagrees with test", Abort);
#endif
Expand Down Expand Up @@ -6592,7 +6593,7 @@ void tst_QString::arg_locale()
}


#ifdef QT_USE_ICU
#if QT_CONFIG(icu)
// Qt has to be built with ICU support
void tst_QString::toUpperLower_icu()
{
Expand Down Expand Up @@ -6626,7 +6627,7 @@ void tst_QString::toUpperLower_icu()
QCOMPARE(l.toLower(sup), sup);
QCOMPARE(l.toLower(QString::fromLatin1("i")), QString::fromLatin1("i"));
}
#endif
#endif // icu

#if !defined(QT_NO_UNICODE_LITERAL)
// Only tested on c++0x compliant compiler or gcc
Expand Down

0 comments on commit 946c701

Please sign in to comment.