Welcome to mirror list, hosted at ThFree Co, Russian Federation.

testsyncfileitem.cpp « test - github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8b4732f7074dc4c359e40dc8069011ea993ddce7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
 *    This software is in the public domain, furnished "as is", without technical
 *       support, and with no warranty, express or implied, as to its usefulness for
 *          any purpose.
 *          */

#include <QtTest>

#include "syncfileitem.h"

using namespace OCC;

class TestSyncFileItem : public QObject
{
    Q_OBJECT

private slots:
    void initTestCase() {
    }

    void cleanupTestCase() {
    }

    SyncFileItem createItem( const QString& file ) {
        SyncFileItem i;
        i._file = file;
        return i;
    }

    void testComparator_data() {
        QTest::addColumn<SyncFileItem>("a");
        QTest::addColumn<SyncFileItem>("b");
        QTest::addColumn<SyncFileItem>("c");

        QTest::newRow("a1") << createItem("client") << createItem("client/build") << createItem("client-build") ;
        QTest::newRow("a2") << createItem("test/t1") << createItem("test/t2") << createItem("test/t3") ;
        QTest::newRow("a3") << createItem("ABCD") << createItem("abcd") << createItem("zzzz");

        SyncFileItem movedItem1;
        movedItem1._file = "folder/source/file.f";
        movedItem1._renameTarget = "folder/destination/file.f";
        movedItem1._instruction = CSYNC_INSTRUCTION_RENAME;

        QTest::newRow("move1") << createItem("folder/destination") << movedItem1 << createItem("folder/destination-2");
        QTest::newRow("move2") << createItem("folder/destination/1") << movedItem1 << createItem("folder/source");
        QTest::newRow("move3") << createItem("abc") << movedItem1 << createItem("ijk");
    }

    void testComparator() {
        QFETCH( SyncFileItem , a );
        QFETCH( SyncFileItem , b );
        QFETCH( SyncFileItem , c );

        QVERIFY(a < b);
        QVERIFY(b < c);
        QVERIFY(a < c);

        QVERIFY(!(b < a));
        QVERIFY(!(c < b));
        QVERIFY(!(c < a));

        QVERIFY(!(a < a));
        QVERIFY(!(b < b));
        QVERIFY(!(c < c));
    }
};

QTEST_APPLESS_MAIN(TestSyncFileItem)
#include "testsyncfileitem.moc"