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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
|
#include <QtCore/QString>
#include <QtTest/QtTest>
#include <qplacereview.h>
QT_USE_NAMESPACE
class tst_QPlaceReview : public QObject
{
Q_OBJECT
public:
tst_QPlaceReview();
private Q_SLOTS:
void constructorTest();
void supplierTest();
void dateTest();
void descriptionTest();
void languageTest();
void helpfulVotingsTest();
void mediaIdsTest();
void unhelpfulVotingsTest();
void ratingTest();
void reviewIdTest();
void titleTest();
void userIdTest();
void userNameTest();
void originatorUrlTest();
void operatorsTest();
};
tst_QPlaceReview::tst_QPlaceReview()
{
}
void tst_QPlaceReview::constructorTest()
{
QPlaceReview testObj;
testObj.setLanguage("testId");
QPlaceReview *testObjPtr = new QPlaceReview(testObj);
QVERIFY2(testObjPtr != NULL, "Copy constructor - null");
QVERIFY2(*testObjPtr == testObj, "Copy constructor - compare");
delete testObjPtr;
}
void tst_QPlaceReview::supplierTest()
{
QPlaceReview testObj;
QVERIFY2(testObj.supplier().supplierId() == QString(), "Wrong default value");
QPlaceSupplier sup;
sup.setName("testName1");
sup.setSupplierId("testId");
testObj.setSupplier(sup);
QVERIFY2(testObj.supplier() == sup, "Wrong value returned");
}
void tst_QPlaceReview::dateTest()
{
QPlaceReview testObj;
QVERIFY2(testObj.date() == QString(), "Wrong default value");
testObj.setDate("testText");
QVERIFY2(testObj.date() == "testText", "Wrong value returned");
}
void tst_QPlaceReview::descriptionTest()
{
QPlaceReview testObj;
QVERIFY2(testObj.description() == QString(), "Wrong default value");
testObj.setDescription("testText");
QVERIFY2(testObj.description() == "testText", "Wrong value returned");
}
void tst_QPlaceReview::languageTest()
{
QPlaceReview testObj;
QVERIFY2(testObj.language() == QString(), "Wrong default value");
testObj.setLanguage("testText");
QVERIFY2(testObj.language() == "testText", "Wrong value returned");
}
void tst_QPlaceReview::helpfulVotingsTest()
{
QPlaceReview testObj;
QVERIFY2(testObj.helpfulVotings() == 0, "Wrong default value");
testObj.setHelpfulVotings(-10);
QVERIFY2(testObj.helpfulVotings() == -10, "Wrong value returned");
testObj.setHelpfulVotings(3);
QVERIFY2(testObj.helpfulVotings() == 3, "Wrong value returned");
}
void tst_QPlaceReview::mediaIdsTest()
{
QPlaceReview testObj;
QVERIFY2(testObj.mediaIds().count() == 0, "Wrong default value");
QStringList list;
list << "1" << "2" << "3";
testObj.setMediaIds(list);
QVERIFY2(testObj.mediaIds().count() == 3, "Wrong value returned");
QVERIFY2(testObj.mediaIds()[1] == "2", "Wrong [1] value returned");
}
void tst_QPlaceReview::unhelpfulVotingsTest()
{
QPlaceReview testObj;
QVERIFY2(testObj.unhelpfulVotings() == 0, "Wrong default value");
testObj.setUnhelpfulVotings(-10);
QVERIFY2(testObj.unhelpfulVotings() == -10, "Wrong value returned");
testObj.setUnhelpfulVotings(3);
QVERIFY2(testObj.unhelpfulVotings() == 3, "Wrong value returned");
}
void tst_QPlaceReview::ratingTest()
{
QPlaceReview testObj;
QVERIFY2(testObj.rating() == 0, "Wrong default value");
testObj.setRating(-10);
QVERIFY2(testObj.rating() == -10, "Wrong value returned");
testObj.setRating(3.4);
QVERIFY2(testObj.rating() == 3.4, "Wrong value returned");
}
void tst_QPlaceReview::operatorsTest()
{
QPlaceReview testObj;
testObj.setDescription("testValue");
QPlaceReview testObj2;
testObj2 = testObj;
QVERIFY2(testObj == testObj2, "Not copied correctly");
testObj2.setLanguage("testValue2");
QVERIFY2(testObj != testObj2, "Object should be different");
}
void tst_QPlaceReview::reviewIdTest()
{
QPlaceReview testObj;
QVERIFY2(testObj.reviewId() == QString(), "Wrong default value");
testObj.setReviewId("testText");
QVERIFY2(testObj.reviewId() == "testText", "Wrong value returned");
}
void tst_QPlaceReview::titleTest()
{
QPlaceReview testObj;
QVERIFY2(testObj.title() == QString(), "Wrong default value");
testObj.setTitle("testText");
QVERIFY2(testObj.title() == "testText", "Wrong value returned");
}
void tst_QPlaceReview::userIdTest()
{
QPlaceReview testObj;
QVERIFY2(testObj.userId() == QString(), "Wrong default value");
testObj.setUserId("testText");
QVERIFY2(testObj.userId() == "testText", "Wrong value returned");
}
void tst_QPlaceReview::userNameTest()
{
QPlaceReview testObj;
QVERIFY2(testObj.userName() == QString(), "Wrong default value");
testObj.setUserName("testText");
QVERIFY2(testObj.userName() == "testText", "Wrong value returned");
}
void tst_QPlaceReview::originatorUrlTest()
{
QPlaceReview testObj;
const QUrl testUrl = QUrl::fromEncoded("http://example.com/testUrl");
QVERIFY2(testObj.originatorUrl() == QUrl(), "Wrong default value");
testObj.setOriginatorUrl(testUrl);
QVERIFY2(testObj.originatorUrl() == testUrl, "Wrong value returned");
}
QTEST_APPLESS_MAIN(tst_QPlaceReview);
#include "tst_qplacereview.moc"
|