testsyncfileitem.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * This software is in the public domain, furnished "as is", without technical
  3. * support, and with no warranty, express or implied, as to its usefulness for
  4. * any purpose.
  5. * */
  6. #include <QtTest>
  7. #include "syncfileitem.h"
  8. using namespace OCC;
  9. class TestSyncFileItem : public QObject
  10. {
  11. Q_OBJECT
  12. private slots:
  13. void initTestCase() {
  14. }
  15. void cleanupTestCase() {
  16. }
  17. OCC::SyncFileItem createItem( const QString& file ) {
  18. SyncFileItem i;
  19. i._file = file;
  20. return i;
  21. }
  22. void testComparator_data() {
  23. QTest::addColumn<SyncFileItem>("a");
  24. QTest::addColumn<SyncFileItem>("b");
  25. QTest::addColumn<SyncFileItem>("c");
  26. QTest::newRow("a1") << createItem("client") << createItem("client/build") << createItem("client-build") ;
  27. QTest::newRow("a2") << createItem("test/t1") << createItem("test/t2") << createItem("test/t3") ;
  28. QTest::newRow("a3") << createItem("ABCD") << createItem("abcd") << createItem("zzzz");
  29. SyncFileItem movedItem1;
  30. movedItem1._file = "folder/source/file.f";
  31. movedItem1._renameTarget = "folder/destination/file.f";
  32. movedItem1._instruction = CSYNC_INSTRUCTION_RENAME;
  33. QTest::newRow("move1") << createItem("folder/destination") << movedItem1 << createItem("folder/destination-2");
  34. QTest::newRow("move2") << createItem("folder/destination/1") << movedItem1 << createItem("folder/source");
  35. QTest::newRow("move3") << createItem("abc") << movedItem1 << createItem("ijk");
  36. }
  37. void testComparator() {
  38. QFETCH( SyncFileItem , a );
  39. QFETCH( SyncFileItem , b );
  40. QFETCH( SyncFileItem , c );
  41. QVERIFY(a < b);
  42. QVERIFY(b < c);
  43. QVERIFY(a < c);
  44. QVERIFY(!(b < a));
  45. QVERIFY(!(c < b));
  46. QVERIFY(!(c < a));
  47. QVERIFY(!(a < a));
  48. QVERIFY(!(b < b));
  49. QVERIFY(!(c < c));
  50. }
  51. };
  52. QTEST_APPLESS_MAIN(TestSyncFileItem)
  53. #include "testsyncfileitem.moc"