summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2017-01-31 09:34:49 +0100
committerMarc Mutz <marc.mutz@kdab.com>2017-03-29 12:29:52 +0000
commit46351b4e601ee0e87c4a8467785c1e5718565190 (patch)
tree73b495e0b635eb9aa4c73834449a731bf53c0f8d /tests
parent718023606370d7c0f972acb0ba83df3383b8800a (diff)
QColor: port to QStringView
... leveraging the existing support for QLatin1String, which is the char equivalent of QStringView. The only noteworthy changes here are the port of the low-level functions to size_t and that the internal template function, setColorFromString(), can now take its argument by value, since only views are ever passed to it anymore. In the test, used new QTest::addRow() to format test names, and introduced temporaries to avoid re-calculating the same input values for every check. Change-Id: Ia3c59e5c435ff753f34993a8d85c0c0b4e8e2b22 Reviewed-by: Milian Wolff <milian.wolff@kdab.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/gui/painting/qcolor/tst_qcolor.cpp27
1 files changed, 20 insertions, 7 deletions
diff --git a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
index 1ce7e797fc..6809aea086 100644
--- a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
+++ b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
@@ -545,19 +545,32 @@ void tst_QColor::setNamedColor_data()
QColor bySetNamedColor; \
bySetNamedColor.setNamedColor(expr); \
auto byCtor = QColor(expr); \
- QTest::newRow(e.name + QByteArrayLiteral(#expr)) \
+ QTest::addRow("%s: %s", e.name, #expr) \
<< byCtor << bySetNamedColor << expected; \
} while (0) \
/*end*/
- ROW(QLatin1String(e.name));
- ROW(QString(QLatin1String(e.name)));
+ const auto l1 = QLatin1String(e.name);
+ const auto l1UpperBA = QByteArray(e.name).toUpper();
+ const auto l1Upper = QLatin1String(l1UpperBA);
+ const auto l1SpaceBA = QByteArray(e.name).insert(1, ' ');
+ const auto l1Space = QLatin1String(l1SpaceBA);
+
+ const auto u16 = QString(l1);
+ const auto u16Upper = u16.toUpper();
+ const auto u16Space = QString(u16).insert(1, ' ');
+
+ ROW(l1);
+ ROW(u16);
+ ROW(QStringView(u16));
// name should be case insensitive
- ROW(QLatin1String(QByteArray(e.name).toUpper()));
- ROW(QString(e.name).toUpper());
+ ROW(l1Upper);
+ ROW(u16Upper);
+ ROW(QStringView(u16Upper));
// spaces should be ignored
- ROW(QLatin1String(QByteArray(e.name).insert(1, ' ')));
- ROW(QString(e.name).insert(1, ' '));
+ ROW(l1Space);
+ ROW(u16Space);
+ ROW(QStringView(u16Space));
#undef ROW
}
}