Fix QStringList::sort test
Checking that the result of sort() is a specific list is wrong, as sort() can put equivalent elements in an arbitrary order. Change-Id: Ib06399cdecedb6cf01e721d4d92048449d66b40d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>bb10
parent
2b308d4cb5
commit
8cb319939a
|
|
@ -228,7 +228,14 @@ void tst_QStringList::sort()
|
|||
list3 << "alpha" << "beta" << "BETA" << "gamma" << "Gamma" << "gAmma" << "epsilon";
|
||||
list3.sort(Qt::CaseInsensitive);
|
||||
list4 << "alpha" << "beta" << "BETA" << "epsilon" << "Gamma" << "gAmma" << "gamma";
|
||||
QCOMPARE( list3, list4 );
|
||||
// with this list, case insensitive sorting can give more than one permutation for "equivalent"
|
||||
// elements; so we check that the sort gave the formally correct result (list[i] <= list[i+1])
|
||||
for (int i = 0; i < list4.count() - 1; ++i)
|
||||
QVERIFY2(QString::compare(list4.at(i), list4.at(i + 1), Qt::CaseInsensitive) <= 0, qPrintable(QString("index %1 failed").arg(i)));
|
||||
// additional checks
|
||||
QCOMPARE(list4.at(0), QString("alpha"));
|
||||
QVERIFY(list4.indexOf("epsilon") > 0);
|
||||
QVERIFY(list4.indexOf("epsilon") < (list4.count() - 1));
|
||||
#ifdef Q_OS_WINCE
|
||||
SetUserDefaultLCID(oldLcid);
|
||||
#else
|
||||
|
|
|
|||
Loading…
Reference in New Issue