diff options
Diffstat (limited to 'tests/auto/corelib/text/qchar/tst_qchar.cpp')
-rw-r--r-- | tests/auto/corelib/text/qchar/tst_qchar.cpp | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/tests/auto/corelib/text/qchar/tst_qchar.cpp b/tests/auto/corelib/text/qchar/tst_qchar.cpp index bb1b4b146c..fae507f4c6 100644 --- a/tests/auto/corelib/text/qchar/tst_qchar.cpp +++ b/tests/auto/corelib/text/qchar/tst_qchar.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QTest> #include <qchar.h> @@ -17,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(); @@ -174,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'); @@ -774,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++; |