summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2015-12-13 03:43:00 +0100
committerMarc Mutz <marc.mutz@kdab.com>2016-04-05 19:47:37 +0000
commite0ea0f6178c9dbee2a8c888fde84ad1cd9670c6b (patch)
treeb05dbbfd6b8e5112368739b80e76d7415d01ceaf /tests
parent96678806d676fda9f0e47e2a9fef3c0300e7fe55 (diff)
QChar: optimize comparison with QString{,Ref}
Instead of relying on the QString relational operators to implicitly convert the QChar to a QString, add relational operator overloads that compare the QChar without first turning it into a QString, saving one memory allocation per comparison, and allowing to mark the operation as nothrow. Consequently, in tst_QStringBinOps, verify now that all relational operations are noexcept. The added overloads make QChar ==/!= int comparisons ambiguous. De-ambiguate by providing a constrained template that matches int and nothing but int (otherwise, the QChar and the int versions would compete for a QChar::SpecialCharacter argument, and end up creating new ambiguities). This solution may not be perfect, but it can be easily extended should more ambiguities crop up. The existing overload deals with all patterns found in qtbase. Change-Id: I4156d918e9b9134c1da684b8b69e0ee526ad24e3 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/tools/qstringapisymmetry/tst_qstringapisymmetry.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qstringapisymmetry/tst_qstringapisymmetry.cpp b/tests/auto/corelib/tools/qstringapisymmetry/tst_qstringapisymmetry.cpp
index f0d7cb5698..f6d2579074 100644
--- a/tests/auto/corelib/tools/qstringapisymmetry/tst_qstringapisymmetry.cpp
+++ b/tests/auto/corelib/tools/qstringapisymmetry/tst_qstringapisymmetry.cpp
@@ -148,7 +148,14 @@ void tst_QStringApiSymmetry::compare_impl() const
const LHS lhs = make<LHS>(lhsUnicode, lhsLatin1);
const RHS rhs = make<RHS>(rhsUnicode, rhsLatin1);
+#ifdef Q_COMPILER_NOEXCEPT
+# define QVERIFY_NOEXCEPT(expr) QVERIFY(noexcept(expr))
+#else
+# define QVERIFY_NOEXCEPT(expr)
+#endif
+
#define CHECK(op) \
+ QVERIFY_NOEXCEPT(lhs op rhs); \
do { if (caseSensitiveCompareResult op 0) { \
QVERIFY(lhs op rhs); \
} else { \