Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
6.0.0 Beta5
-
None
Description
While extending tst_QCollator to support QCollatorSortKey, I've noticed that on platforms without ICU (!QT_CONFIG(icu)) the result of QCollatorSortKey::compare is not always equal to the results of QCollator::compare.
Sample code to illustrate the problem
auto asSign = [](int compared) { return compared < 0 ? -1 : compared > 0 ? 1 : 0; }; QString str1("some str"); QString str2("some other str"); QCollator collator(/*some initialization params*/); int collatorResult = asSign(collator.compare(str1, str2)); QCollatorSortKey key1 = collator.sortKey(str1); QCollatorSortKey key2 = collator.sortKey(str2); int collatorKeyResult = asSign(key1.compare(key2));
Based on the parameters of collator (case sensitivity, numeric mode, ignore punctuation) the results of the 2 comparisons can be equal or different, which is quite confusing for me.
A real code for the test can be found in qtbase/tests/auto/corelib/text/qcollator/tst_qcollator.cpp
Good starting points are qtbase/src/corelib/text/qcollator_macx.cpp (for Mac) and qtbase/src/corelib/text/qcollator_win.cpp (for Windows)
Attachments
Issue Links
- is duplicated by
-
QTBUG-108756 QCollatorSortKey gives wrong compare result
- Reported
- relates to
-
QTBUG-88546 Improve QCollator testing
- Closed