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>
bb10
Marc Mutz 2017-02-07 13:10:38 +01:00
parent 68b21690e2
commit b0c1e07d64
2 changed files with 44 additions and 2 deletions

View File

@ -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

View File

@ -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
}
}