summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2017-02-07 13:10:38 +0100
committerMarc Mutz <marc.mutz@kdab.com>2017-02-11 07:37:22 +0000
commitb0c1e07d648caf585d2be12cf3d18eb42b86f721 (patch)
tree63d3570533758202ad3675ccdd64fc7e1c5c81ec /tests
parent68b21690e25533e0c35f4e29f6b373fb09b117a3 (diff)
Add tests for QCollatorSortKey
There weren't any, at all. Testing on the CI showed that the implementation is broken on macOS, and, to a lesser extent, on Windows, so blacklist the failing tests until the implementation can be fixed. No need to hold back testing the other implementations. Task-number: QTBUG-58737 Change-Id: I9ae16ab778dbe2e95a6ca5e0bae00df4bad65cb2 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/tools/qcollator/BLACKLIST18
-rw-r--r--tests/auto/corelib/tools/qcollator/tst_qcollator.cpp28
2 files changed, 44 insertions, 2 deletions
diff --git a/tests/auto/corelib/tools/qcollator/BLACKLIST b/tests/auto/corelib/tools/qcollator/BLACKLIST
new file mode 100644
index 0000000000..09b69e0108
--- /dev/null
+++ b/tests/auto/corelib/tools/qcollator/BLACKLIST
@@ -0,0 +1,18 @@
+[compare:swedish5]
+osx
+[compare:norwegian4]
+osx
+[compare:german6]
+osx
+windows
+[compare:german7]
+osx
+windows
+[compare:german8]
+osx
+[compare:german9]
+osx
+[compare:german10]
+osx
+[compare:french5]
+osx
diff --git a/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp b/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp
index d09910fd5c..ead0992f92 100644
--- a/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp
+++ b/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp
@@ -33,6 +33,11 @@
#include <cstring>
+Q_CONSTEXPR inline int sign(int i) Q_DECL_NOTHROW
+{ return i < 0 ? -1 : i > 0 ? 1 : 0; }
+
+#define QCOMPARE_SIGN(x, y) QCOMPARE(sign(x), sign(y))
+
class tst_QCollator : public QObject
{
Q_OBJECT
@@ -173,9 +178,28 @@ void tst_QCollator::compare()
if (numericMode)
collator.setNumericMode(true);
- QCOMPARE(collator.compare(s1, s2), result);
+ QCOMPARE_SIGN(collator.compare(s1, s2), result);
+ {
+ const auto s1sk = collator.sortKey(s1);
+ const auto s2sk = collator.sortKey(s2);
+
+ QCOMPARE_SIGN(s1sk.compare(s2sk), result);
+#define CHECK(op) QCOMPARE(s1sk op s2sk, result op 0)
+ CHECK(<);
+#undef CHECK
+ }
+
collator.setCaseSensitivity(Qt::CaseInsensitive);
- QCOMPARE(collator.compare(s1, s2), caseInsensitiveResult);
+ QCOMPARE_SIGN(collator.compare(s1, s2), caseInsensitiveResult);
+ {
+ const auto s1sk = collator.sortKey(s1);
+ const auto s2sk = collator.sortKey(s2);
+
+ QCOMPARE_SIGN(s1sk.compare(s2sk), caseInsensitiveResult);
+#define CHECK(op) QCOMPARE(s1sk op s2sk, caseInsensitiveResult op 0)
+ CHECK(<);
+#undef CHECK
+ }
}