Changeset View
Changeset View
Standalone View
Standalone View
autotests/kfileitemtest.cpp
Show First 20 Lines • Show All 92 Lines • ▼ Show 20 Line(s) | 284 | { | |||
---|---|---|---|---|---|
289 | fileItem.setDelayedMimeTypes(true); | 289 | fileItem.setDelayedMimeTypes(true); | ||
290 | KFileItem fileItem2(QUrl::fromLocalFile(file.fileName())); | 290 | KFileItem fileItem2(QUrl::fromLocalFile(file.fileName())); | ||
291 | QVERIFY(fileItem == fileItem2); // created independently, but still 'equal' | 291 | QVERIFY(fileItem == fileItem2); // created independently, but still 'equal' | ||
292 | QVERIFY(fileItem.d != fileItem2.d); | 292 | QVERIFY(fileItem.d != fileItem2.d); | ||
293 | QVERIFY(!(fileItem != fileItem2)); | 293 | QVERIFY(!(fileItem != fileItem2)); | ||
294 | QVERIFY(fileItem.cmp(fileItem2)); | 294 | QVERIFY(fileItem.cmp(fileItem2)); | ||
295 | } | 295 | } | ||
296 | 296 | | |||
297 | void KFileItemTest::testCmpByUrl() | ||||
298 | { | ||||
299 | KFileItem nulFileItem; | ||||
300 | KFileItem fileItem(QUrl::fromLocalFile(QStringLiteral("1foo"))); | ||||
301 | KFileItem fileItem2(QUrl::fromLocalFile(QStringLiteral("fo1"))); | ||||
302 | KFileItem fileItem3(QUrl::fromLocalFile(QStringLiteral("foo"))); | ||||
303 | const QUrl nulUrl; | ||||
304 | const QUrl url = QUrl::fromLocalFile(QStringLiteral("1foo")); | ||||
305 | const QUrl url2 = QUrl::fromLocalFile(QStringLiteral("fo1")); | ||||
dfaure: I wonder if that should be true, though ;-)
I guess it should rather be false, so that a… | |||||
306 | const QUrl url3 = QUrl::fromLocalFile(QStringLiteral("foo")); | ||||
307 | | ||||
308 | // an invalid KFileItem, without url, is considered equal to any other invalid KFileItem or QUrl. | ||||
309 | QVERIFY(!(nulFileItem < nulFileItem)); | ||||
310 | QVERIFY(!(nulFileItem < nulUrl)); | ||||
311 | // an invalid KFileItem is considered less than any valid KFileItem. | ||||
312 | QVERIFY(nulFileItem < fileItem); | ||||
313 | // a valid KFileItem is not less than an invalid KFileItem or invalid QUrl | ||||
314 | QVERIFY(!(fileItem < nulUrl)); | ||||
dfaure: ... exactly. I think the same reasoning applies to a null item. | |||||
315 | QVERIFY(!(fileItem < nulFileItem)); | ||||
316 | | ||||
317 | QVERIFY(fileItem < fileItem2); | ||||
318 | QVERIFY(fileItem < url2); | ||||
319 | QVERIFY(!(fileItem2 < fileItem)); | ||||
320 | QVERIFY(fileItem2 < fileItem3); | ||||
321 | QVERIFY(fileItem < url3); | ||||
322 | QVERIFY(!(fileItem3 < fileItem2)); | ||||
323 | QVERIFY(!(fileItem3 < fileItem)); | ||||
324 | // This should be false as they are equal | ||||
325 | QVERIFY(!(fileItem < fileItem)); | ||||
326 | QVERIFY(!(fileItem < url)); | ||||
327 | } | ||||
328 | | ||||
297 | void KFileItemTest::testRename() | 329 | void KFileItemTest::testRename() | ||
298 | { | 330 | { | ||
299 | KIO::UDSEntry entry; | 331 | KIO::UDSEntry entry; | ||
300 | const QString origName = QStringLiteral("foo"); | 332 | const QString origName = QStringLiteral("foo"); | ||
301 | entry.insert(KIO::UDSEntry::UDS_NAME, origName); | 333 | entry.insert(KIO::UDSEntry::UDS_NAME, origName); | ||
302 | entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR); | 334 | entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR); | ||
303 | KFileItem fileItem(entry, QUrl::fromLocalFile(QStringLiteral("/dir/foo"))); | 335 | KFileItem fileItem(entry, QUrl::fromLocalFile(QStringLiteral("/dir/foo"))); | ||
304 | QCOMPARE(fileItem.name(), origName); | 336 | QCOMPARE(fileItem.name(), origName); | ||
▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines |
I wonder if that should be true, though ;-)
I guess it should rather be false, so that a binary search (based on < only) can deduce that a null item is *equal* to another null item, rather than both being lower than the other, which would be nonsense.