summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/text/qchar/tst_qchar.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/text/qchar/tst_qchar.cpp')
-rw-r--r--tests/auto/corelib/text/qchar/tst_qchar.cpp78
1 files changed, 44 insertions, 34 deletions
diff --git a/tests/auto/corelib/text/qchar/tst_qchar.cpp b/tests/auto/corelib/text/qchar/tst_qchar.cpp
index fe7fd24544..fae507f4c6 100644
--- a/tests/auto/corelib/text/qchar/tst_qchar.cpp
+++ b/tests/auto/corelib/text/qchar/tst_qchar.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
#include <qchar.h>
@@ -42,6 +17,8 @@ private slots:
void operator_eqeq_null();
void operators_data();
void operators();
+ void qchar_qlatin1char_operators_symmetry_data();
+ void qchar_qlatin1char_operators_symmetry();
void toUpper();
void toLower();
void toTitle();
@@ -67,8 +44,10 @@ private slots:
void mirroredChar();
void decomposition();
void script();
+#if !defined(Q_OS_WASM)
void normalization_data();
void normalization();
+#endif // !defined(Q_OS_WASM)
void normalization_manual();
void normalizationCorrections();
void unicodeVersion();
@@ -89,9 +68,9 @@ void tst_QChar::fromUcs4_data()
QTest::addRow("0x%08X", ucs4) << ucs4;
};
- row(0x2f868);
- row(0x1D157);
- row(0x1D157);
+ row(0x2f868); // a CJK Compatibility Ideograph
+ row(0x11139); // Chakma digit 3
+ row(0x1D157); // Musical Symbol Void Notehead
}
void tst_QChar::fromUcs4()
@@ -197,6 +176,36 @@ void tst_QChar::operators()
#undef CHECK
}
+void tst_QChar::qchar_qlatin1char_operators_symmetry_data()
+{
+ QTest::addColumn<char>("lhs");
+ QTest::addColumn<char>("rhs");
+
+ const uchar values[] = {0x00, 0x3a, 0x7f, 0x80, 0xab, 0xff};
+
+ for (uchar i : values) {
+ for (uchar j : values)
+ QTest::addRow("'\\x%02x'_op_'\\x%02x'", i, j) << char(i) << char(j);
+ }
+}
+
+void tst_QChar::qchar_qlatin1char_operators_symmetry()
+{
+ QFETCH(char, lhs);
+ QFETCH(char, rhs);
+
+ const QLatin1Char l1lhs(lhs);
+ const QLatin1Char l1rhs(rhs);
+#define CHECK(op) QCOMPARE((l1lhs op l1rhs), (QChar(l1lhs) op QChar(l1rhs)))
+ CHECK(==);
+ CHECK(!=);
+ CHECK(< );
+ CHECK(> );
+ CHECK(<=);
+ CHECK(>=);
+#undef CHECK
+}
+
void tst_QChar::toUpper()
{
QVERIFY(QChar('a').toUpper() == 'A');
@@ -784,6 +793,8 @@ void tst_QChar::script()
QVERIFY(QChar::script(0xe0100) == QChar::Script_Inherited);
}
+// wasm is limited in reading filesystems, so omit this test for now
+#if !defined(Q_OS_WASM)
void tst_QChar::normalization_data()
{
QTest::addColumn<QStringList>("columns");
@@ -795,9 +806,7 @@ void tst_QChar::normalization_data()
QString testFile = QFINDTESTDATA("data/NormalizationTest.txt");
QVERIFY2(!testFile.isEmpty(), "data/NormalizationTest.txt not found!");
QFile f(testFile);
- QVERIFY(f.exists());
-
- f.open(QIODevice::ReadOnly);
+ QVERIFY(f.open(QIODevice::ReadOnly));
while (!f.atEnd()) {
linenum++;
@@ -822,7 +831,7 @@ void tst_QChar::normalization_data()
line = line.trimmed();
if (line.endsWith(';'))
- line.truncate(line.length()-1);
+ line.truncate(line.size()-1);
QList<QByteArray> l = line.split(';');
@@ -906,6 +915,7 @@ void tst_QChar::normalization()
// #################
}
+#endif // !defined(Q_OS_WASM)
void tst_QChar::normalization_manual()
{