summaryrefslogtreecommitdiffstats
path: root/tests/auto/qchar
diff options
context:
space:
mode:
authorRitt Konstantin <ritt.ks@gmail.com>2010-05-20 08:47:21 (GMT)
committerOlivier Goffart <olivier.goffart@nokia.com>2010-05-20 08:47:21 (GMT)
commit89a5f382e1eff75c3d3f015b3fce0a58b8079e04 (patch)
tree16e5a2d3ee790ea3d00177b27c35c7cb6b365bf7 /tests/auto/qchar
parent9c13272ddeea2408c83eb12a9f1fcceeb6a7589e (diff)
downloadQt-89a5f382e1eff75c3d3f015b3fce0a58b8079e04.zip
Qt-89a5f382e1eff75c3d3f015b3fce0a58b8079e04.tar.gz
Qt-89a5f382e1eff75c3d3f015b3fce0a58b8079e04.tar.bz2
improve Unicode Normalization autotest
Merge-request: 2392 Reviewed-by: Olivier Goffart <olivier.goffart@nokia.com>
Diffstat (limited to 'tests/auto/qchar')
-rw-r--r--tests/auto/qchar/tst_qchar.cpp85
1 files changed, 57 insertions, 28 deletions
diff --git a/tests/auto/qchar/tst_qchar.cpp b/tests/auto/qchar/tst_qchar.cpp
index 9f70b8c..93aaf96 100644
--- a/tests/auto/qchar/tst_qchar.cpp
+++ b/tests/auto/qchar/tst_qchar.cpp
@@ -43,6 +43,7 @@
#include <QtTest/QtTest>
#include <qchar.h>
#include <qfile.h>
+#include <qstringlist.h>
#include <private/qunicodetables_p.h>
#if defined(Q_OS_WINCE)
#include <qcoreapplication.h>
@@ -84,7 +85,9 @@ private slots:
void decomposition();
// void ligature();
void lineBreakClass();
+ void normalization_data();
void normalization();
+ void normalization_manual();
void normalizationCorrections();
void unicodeVersion();
#if defined(Q_OS_WINCE)
@@ -505,31 +508,13 @@ void tst_QChar::lineBreakClass()
QVERIFY(QUnicodeTables::lineBreakClass(0x0fffdu) == QUnicodeTables::LineBreak_AL);
}
-void tst_QChar::normalization()
+void tst_QChar::normalization_data()
{
- {
- QString composed;
- composed += QChar(0xc0);
- QString decomposed;
- decomposed += QChar(0x41);
- decomposed += QChar(0x300);
+ QTest::addColumn<QStringList>("columns");
+ QTest::addColumn<int>("part");
- QVERIFY(composed.normalized(QString::NormalizationForm_D) == decomposed);
- QVERIFY(composed.normalized(QString::NormalizationForm_C) == composed);
- QVERIFY(composed.normalized(QString::NormalizationForm_KD) == decomposed);
- QVERIFY(composed.normalized(QString::NormalizationForm_KC) == composed);
- }
- {
- QString composed;
- composed += QChar(0xa0);
- QString decomposed;
- decomposed += QChar(0x20);
-
- QVERIFY(composed.normalized(QString::NormalizationForm_D) == composed);
- QVERIFY(composed.normalized(QString::NormalizationForm_C) == composed);
- QVERIFY(composed.normalized(QString::NormalizationForm_KD) == decomposed);
- QVERIFY(composed.normalized(QString::NormalizationForm_KC) == decomposed);
- }
+ int linenum = 0;
+ int part = 0;
QFile f(SRCDIR "NormalizationTest.txt");
QVERIFY(f.exists());
@@ -537,6 +522,8 @@ void tst_QChar::normalization()
f.open(QIODevice::ReadOnly);
while (!f.atEnd()) {
+ linenum++;
+
QByteArray line;
line.resize(1024);
int len = f.readLine(line.data(), 1024);
@@ -546,8 +533,11 @@ void tst_QChar::normalization()
if (comment >= 0)
line = line.left(comment);
- if (line.startsWith("@"))
+ if (line.startsWith("@")) {
+ if (line.startsWith("@Part") && line.size() > 5 && QChar(line.at(5)).isDigit())
+ part = QChar(line.at(5)).digitValue();
continue;
+ }
if (line.isEmpty())
continue;
@@ -560,8 +550,10 @@ void tst_QChar::normalization()
Q_ASSERT(l.size() == 5);
- QString columns[5];
+ QStringList columns;
for (int i = 0; i < 5; ++i) {
+ columns.append(QString());
+
QList<QByteArray> c = l.at(i).split(' ');
Q_ASSERT(!c.isEmpty());
@@ -572,15 +564,26 @@ void tst_QChar::normalization()
columns[i].append(QChar(uc));
else {
// convert to utf16
- uc -= 0x10000;
- ushort high = uc/0x400 + 0xd800;
- ushort low = uc%0x400 + 0xdc00;
+ ushort high = QChar::highSurrogate(uc);
+ ushort low = QChar::lowSurrogate(uc);
columns[i].append(QChar(high));
columns[i].append(QChar(low));
}
}
}
+ QString nm = QString("line #%1:").arg(linenum);
+ QTest::newRow(nm.toLatin1()) << columns << part;
+ }
+}
+
+void tst_QChar::normalization()
+{
+ QFETCH(QStringList, columns);
+ QFETCH(int, part);
+
+ Q_UNUSED(part)
+
// CONFORMANCE:
// 1. The following invariants must be true for all conformant implementations
//
@@ -630,6 +633,32 @@ void tst_QChar::normalization()
// #################
+}
+
+void tst_QChar::normalization_manual()
+{
+ {
+ QString composed;
+ composed += QChar(0xc0);
+ QString decomposed;
+ decomposed += QChar(0x41);
+ decomposed += QChar(0x300);
+
+ QVERIFY(composed.normalized(QString::NormalizationForm_D) == decomposed);
+ QVERIFY(composed.normalized(QString::NormalizationForm_C) == composed);
+ QVERIFY(composed.normalized(QString::NormalizationForm_KD) == decomposed);
+ QVERIFY(composed.normalized(QString::NormalizationForm_KC) == composed);
+ }
+ {
+ QString composed;
+ composed += QChar(0xa0);
+ QString decomposed;
+ decomposed += QChar(0x20);
+
+ QVERIFY(composed.normalized(QString::NormalizationForm_D) == composed);
+ QVERIFY(composed.normalized(QString::NormalizationForm_C) == composed);
+ QVERIFY(composed.normalized(QString::NormalizationForm_KD) == decomposed);
+ QVERIFY(composed.normalized(QString::NormalizationForm_KC) == decomposed);
}
}