Changeset View
Changeset View
Standalone View
Standalone View
autotests/kfileitemtest.cpp
Show First 20 Lines • Show All 288 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 | const QUrl nulUrl; | ||||
300 | const QUrl url = QUrl::fromLocalFile(QStringLiteral("1foo")); | ||||
301 | const QUrl url2 = QUrl::fromLocalFile(QStringLiteral("fo1")); | ||||
302 | const QUrl url3 = QUrl::fromLocalFile(QStringLiteral("foo")); | ||||
303 | KFileItem nulFileItem; | ||||
304 | KFileItem nulFileItem2(nulUrl); | ||||
305 | KFileItem fileItem(url); | ||||
dfaure: I wonder if that should be true, though ;-)
I guess it should rather be false, so that a… | |||||
306 | KFileItem fileItem2(url2); | ||||
307 | KFileItem fileItem3(url3); | ||||
308 | | ||||
309 | // an invalid KFileItem is considered equal to any other invalid KFileItem or invalid QUrl. | ||||
310 | QVERIFY(!(nulFileItem < nulFileItem)); | ||||
311 | QVERIFY(!(nulFileItem < nulFileItem2)); | ||||
312 | QVERIFY(!(nulFileItem2 < nulFileItem)); | ||||
313 | QVERIFY(!(nulFileItem < nulUrl)); | ||||
314 | // an invalid KFileItem is considered less than any valid KFileItem. | ||||
dfaure: ... exactly. I think the same reasoning applies to a null item. | |||||
315 | QVERIFY(nulFileItem < fileItem); | ||||
316 | // a valid KFileItem is not less than an invalid KFileItem or invalid QUrl | ||||
317 | QVERIFY(!(fileItem < nulUrl)); | ||||
318 | QVERIFY(!(fileItem < nulFileItem)); | ||||
319 | QVERIFY(!(fileItem < nulFileItem2)); | ||||
320 | | ||||
321 | QVERIFY(fileItem < fileItem2); | ||||
322 | QVERIFY(fileItem < url2); | ||||
323 | QVERIFY(!(fileItem2 < fileItem)); | ||||
324 | QVERIFY(fileItem2 < fileItem3); | ||||
325 | QVERIFY(fileItem < url3); | ||||
326 | QVERIFY(!(fileItem3 < fileItem2)); | ||||
327 | QVERIFY(!(fileItem3 < fileItem)); | ||||
328 | // Must be false as they are considered equal | ||||
329 | QVERIFY(!(fileItem < fileItem)); | ||||
330 | QVERIFY(!(fileItem < url)); | ||||
331 | } | ||||
332 | | ||||
297 | void KFileItemTest::testRename() | 333 | void KFileItemTest::testRename() | ||
298 | { | 334 | { | ||
299 | KIO::UDSEntry entry; | 335 | KIO::UDSEntry entry; | ||
300 | const QString origName = QStringLiteral("foo"); | 336 | const QString origName = QStringLiteral("foo"); | ||
301 | entry.insert(KIO::UDSEntry::UDS_NAME, origName); | 337 | entry.insert(KIO::UDSEntry::UDS_NAME, origName); | ||
302 | entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR); | 338 | entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR); | ||
303 | KFileItem fileItem(entry, QUrl::fromLocalFile(QStringLiteral("/dir/foo"))); | 339 | KFileItem fileItem(entry, QUrl::fromLocalFile(QStringLiteral("/dir/foo"))); | ||
304 | QCOMPARE(fileItem.name(), origName); | 340 | QCOMPARE(fileItem.name(), origName); | ||
▲ Show 20 Lines • Show All 363 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.