summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKonstantin Ritt <ritt.ks@gmail.com>2012-05-10 12:07:58 +0300
committerQt by Nokia <qt-info@nokia.com>2012-05-11 01:42:02 +0200
commit3f9b5086525ac4552fd4d7cc89c74bf76f45b1dc (patch)
tree805dc314effa82dfc2d7fceada7aa678b108d580 /tests
parentc2f8fe64f1273ed25a8e5834f86dc19b79805855 (diff)
fix QString::isRightToLeft() for SMP code points
Change-Id: Ib8afc932d9566df1a8922da9a75b9f9cbbdd321d Reviewed-by: Lars Knoll <lars.knoll@nokia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/tools/qstring/tst_qstring.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
index ed3f04a57f..78a19830a1 100644
--- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp
+++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
@@ -239,6 +239,8 @@ private slots:
void compareQLatin1Strings();
void fromQLatin1StringWithLength();
void assignQLatin1String();
+ void isRightToLeft_data();
+ void isRightToLeft();
};
template <class T> const T &verifyZeroTermination(const T &t) { return t; }
@@ -5627,6 +5629,39 @@ void tst_QString::assignQLatin1String()
}
+void tst_QString::isRightToLeft_data()
+{
+ QTest::addColumn<QString>("unicode");
+ QTest::addColumn<bool>("rtl");
+
+ QTest::newRow("null") << QString() << false;
+ QTest::newRow("empty") << QString("") << false;
+
+ QTest::newRow("numbers-only") << QString("12345") << false;
+ QTest::newRow("latin1-only") << QString("hello") << false;
+ QTest::newRow("numbers-latin1") << (QString("12345") + QString("hello")) << false;
+
+ static const ushort unicode1[] = { 0x627, 0x627 };
+ QTest::newRow("arabic-only") << QString::fromUtf16(unicode1, 2) << true;
+ QTest::newRow("numbers-arabic") << (QString("12345") + QString::fromUtf16(unicode1, 2)) << true;
+ QTest::newRow("numbers-latin1-arabic") << (QString("12345") + QString("hello") + QString::fromUtf16(unicode1, 2)) << false;
+ QTest::newRow("numbers-arabic-latin1") << (QString("12345") + QString::fromUtf16(unicode1, 2) + QString("hello")) << true;
+
+ static const ushort unicode2[] = { QChar::highSurrogate(0xE01DAu), QChar::lowSurrogate(0xE01DAu), QChar::highSurrogate(0x2F800u), QChar::lowSurrogate(0x2F800u) };
+ QTest::newRow("surrogates-VS-CJK") << QString::fromUtf16(unicode2, 4) << false;
+
+ static const ushort unicode3[] = { QChar::highSurrogate(0x10800u), QChar::lowSurrogate(0x10800u), QChar::highSurrogate(0x10805u), QChar::lowSurrogate(0x10805u) };
+ QTest::newRow("surrogates-cypriot") << QString::fromUtf16(unicode3, 4) << true;
+}
+
+void tst_QString::isRightToLeft()
+{
+ QFETCH(QString, unicode);
+ QFETCH(bool, rtl);
+
+ QCOMPARE(unicode.isRightToLeft(), rtl);
+}
+
QTEST_APPLESS_MAIN(tst_QString)
#include "tst_qstring.moc"