summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/text
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2020-07-10 11:41:33 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-07-21 22:01:20 +0200
commitd25589e0529732996e405aaff8d6c46b012e1601 (patch)
tree29b596d0c2ca0e36aa9aea65f426ed393c660e78 /tests/auto/gui/text
parentb50daef9771d8829fc7f808898cbe051a5464b79 (diff)
QTestlib: Enable comparing QList against initializer lists/arrays
It is unnecessary to create a QList container just for comparison. Split out helpers for comparing sequence sizes and sequences from qCompare(QList) and add a template for an array with a non-type template parameter for the size. One can then write something like: const int expected[] = {10, 12,...}; QCOMPARE(QFontDatabase.pointSizes(...), expected) Unfortunately, any commas in such an array will be misread by macro expansion as macro argument separators, so any expected array with more than one entry needs an extra macro expanding __VA_ARGS__. Change-Id: Ie7c8dc20bf669bbb25f6d7f8562455f8d03968c8 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'tests/auto/gui/text')
-rw-r--r--tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp b/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp
index 2be683ed13..da8ae5606f 100644
--- a/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp
+++ b/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp
@@ -493,6 +493,9 @@ void tst_QGlyphRun::drawMultiScriptText2()
void tst_QGlyphRun::detach()
{
+
+#define ARG(...) __VA_ARGS__
+
QGlyphRun glyphs;
glyphs.setGlyphIndexes(QList<quint32>() << 1 << 2 << 3);
@@ -504,8 +507,10 @@ void tst_QGlyphRun::detach()
otherGlyphs.setGlyphIndexes(QList<quint32>() << 4 << 5 << 6);
- QCOMPARE(otherGlyphs.glyphIndexes(), QList<quint32>() << 4 << 5 << 6);
- QCOMPARE(glyphs.glyphIndexes(), QList<quint32>() << 1 << 2 << 3);
+ QCOMPARE(otherGlyphs.glyphIndexes(), ARG({4, 5, 6}));
+ QCOMPARE(glyphs.glyphIndexes(), ARG({1, 2, 3}));
+
+#undef ARG
}
void tst_QGlyphRun::drawRightToLeft()