summaryrefslogtreecommitdiff
path: root/tests/auto/qplacerequest/tst_qplacerequest.cpp
blob: 2dedcb63aaf163b770b64eef680200ab78e08ca8 (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
70
71
72
73
74
75
76
77
#include <QtCore/QString>
#include <QtTest/QtTest>

#include <qplacerequest.h>
#include <qplacecontentrequest.h>

QT_USE_NAMESPACE

class tst_QPlaceRequest : public QObject
{
    Q_OBJECT

public:
    tst_QPlaceRequest();

private Q_SLOTS:
    void constructorTest();
    void offsetTest();
    void limitTest();
    void operatorsTest();
};

tst_QPlaceRequest::tst_QPlaceRequest()
{
}

void tst_QPlaceRequest::constructorTest()
{
    QPlaceRequest testObj;
    Q_UNUSED(testObj);

    QPlaceRequest *testObjPtr = new QPlaceRequest(testObj);
    QVERIFY2(testObjPtr != NULL, "Copy constructor - null");
    QVERIFY2(testObjPtr->offset() == 0, "Copy constructor - wrong count");
    QVERIFY2(testObjPtr->limit() == -1, "Copy constructor - wrong value");
    QVERIFY2(*testObjPtr == testObj, "Copy constructor - compare");
    delete testObjPtr;
}

void tst_QPlaceRequest::offsetTest()
{
    QPlaceRequest testObj;
    QVERIFY2(testObj.offset() == 0, "Wrong default value");
    testObj.setOffset(-10);
    QVERIFY2(testObj.offset() == -10, "Wrong negative value returned");
    testObj.setOffset(10203);
    QVERIFY2(testObj.offset() == 10203, "Wrong value returned");
    testObj.clear();
    QVERIFY2(testObj.offset() == 0, "Wrong cleared value returned");
}

void tst_QPlaceRequest::limitTest()
{
    QPlaceRequest testObj;
    QVERIFY2(testObj.limit() == -1, "Wrong default value");
    testObj.setLimit(-10);
    QVERIFY2(testObj.limit() == -10, "Wrong negative value returned");
    testObj.setLimit(10203);
    QVERIFY2(testObj.limit() == 10203, "Wrong value returned");
    testObj.clear();
    QVERIFY2(testObj.limit() == -1, "Wrong cleared value returned");
}

void tst_QPlaceRequest::operatorsTest()
{
    QPlaceRequest testObj;
    testObj.setOffset(2);
    QPlaceRequest testObj2;
    testObj2 = testObj;
    QVERIFY2(testObj == testObj2, "Not copied correctly");
    testObj2.setLimit(-10);
    QVERIFY2(testObj != testObj2, "Object should be different");
}

QTEST_APPLESS_MAIN(tst_QPlaceRequest);

#include "tst_qplacerequest.moc"