|
@@ -9,7 +9,35 @@ private slots:
|
9
|
9
|
void gettersSetters1();
|
10
|
10
|
void gettersSetters2();
|
11
|
11
|
void gettersSetters3();
|
|
12
|
+
|
|
13
|
+ void isNull1();
|
|
14
|
+ void isNull1Op();
|
|
15
|
+ void isNull2();
|
|
16
|
+ void isNull2Op();
|
|
17
|
+
|
|
18
|
+ void equal1();
|
|
19
|
+ void equal2();
|
|
20
|
+ void equal3();
|
|
21
|
+ void equal4();
|
|
22
|
+ void equal5();
|
|
23
|
+ void equal6();
|
|
24
|
+
|
|
25
|
+ void add1();
|
|
26
|
+ void add1Op();
|
|
27
|
+ void add2();
|
|
28
|
+ void add2Op();
|
|
29
|
+ void add3Op();
|
|
30
|
+
|
|
31
|
+ void sub1();
|
|
32
|
+ void sub1Op();
|
|
33
|
+ void sub2();
|
|
34
|
+ void sub2Op();
|
|
35
|
+ void sub3Op();
|
|
36
|
+
|
12
|
37
|
void mult();
|
|
38
|
+ void multOp();
|
|
39
|
+
|
|
40
|
+
|
13
|
41
|
void div();
|
14
|
42
|
};
|
15
|
43
|
|
|
@@ -40,6 +68,214 @@ void TestVector3D::gettersSetters3()
|
40
|
68
|
QCOMPARE(v.getZ(), z);
|
41
|
69
|
}
|
42
|
70
|
|
|
71
|
+void TestVector3D::isNull1()
|
|
72
|
+{
|
|
73
|
+ double x = 1.42, y = 2.0, z = 3.0;
|
|
74
|
+ Vector3D v(x, y, z);
|
|
75
|
+ QCOMPARE(v.isNull(), false);
|
|
76
|
+}
|
|
77
|
+
|
|
78
|
+void TestVector3D::isNull1Op()
|
|
79
|
+{
|
|
80
|
+ double x = 1.42, y = 2.0, z = 3.0;
|
|
81
|
+ Vector3D v(x, y, z);
|
|
82
|
+ QCOMPARE((bool)v, true);
|
|
83
|
+}
|
|
84
|
+
|
|
85
|
+void TestVector3D::isNull2()
|
|
86
|
+{
|
|
87
|
+ Vector3D v;
|
|
88
|
+ QCOMPARE(v.isNull(), true);
|
|
89
|
+}
|
|
90
|
+
|
|
91
|
+void TestVector3D::isNull2Op()
|
|
92
|
+{
|
|
93
|
+ Vector3D v;
|
|
94
|
+ QCOMPARE(!v, true);
|
|
95
|
+}
|
|
96
|
+
|
|
97
|
+void TestVector3D::equal1()
|
|
98
|
+{
|
|
99
|
+ Vector3D v1(1.42, 2.0, 3.0);
|
|
100
|
+ Vector3D v2(1.42, 2.0, 3.0);
|
|
101
|
+ QCOMPARE(v1.equal(v2), true);
|
|
102
|
+}
|
|
103
|
+
|
|
104
|
+void TestVector3D::equal2()
|
|
105
|
+{
|
|
106
|
+ Vector3D v1(1.42, 2.0, 3.0);
|
|
107
|
+ Vector3D v2(1.40, 2.0, 3.0);
|
|
108
|
+ QCOMPARE(v1.equal(v2), false);
|
|
109
|
+}
|
|
110
|
+
|
|
111
|
+void TestVector3D::equal3()
|
|
112
|
+{
|
|
113
|
+ Vector3D v1(1.42, 2.0, 3.0);
|
|
114
|
+ Vector3D v2(1.42, 2.1, 3.0);
|
|
115
|
+ QCOMPARE(v1.equal(v2), false);
|
|
116
|
+}
|
|
117
|
+
|
|
118
|
+void TestVector3D::equal4()
|
|
119
|
+{
|
|
120
|
+ Vector3D v1(1.42, 2.0, 3.0);
|
|
121
|
+ Vector3D v2(1.42, 2.0, 3.1);
|
|
122
|
+ QCOMPARE(v1.equal(v2), false);
|
|
123
|
+}
|
|
124
|
+
|
|
125
|
+void TestVector3D::equal5()
|
|
126
|
+{
|
|
127
|
+ Vector3D v1(1.42, 2.0, 3.0);
|
|
128
|
+ Vector3D v2(1.42, 2.0, 3.1);
|
|
129
|
+ QCOMPARE(v1 == v2, false);
|
|
130
|
+}
|
|
131
|
+
|
|
132
|
+void TestVector3D::equal6()
|
|
133
|
+{
|
|
134
|
+ Vector3D v1(1.42, 2.0, 3.0);
|
|
135
|
+ Vector3D v2(1.42, 2.0, 3.0);
|
|
136
|
+ QCOMPARE(v1 == v2, true);
|
|
137
|
+}
|
|
138
|
+
|
|
139
|
+void TestVector3D::add1()
|
|
140
|
+{
|
|
141
|
+ double x = 1.42, y = 2.0, z = 3.0, x2 = 0.24, y2 = 24.0, z2 = 42.0;
|
|
142
|
+ Vector3D v(x, y, z);
|
|
143
|
+ v.add(x2, y2, z2);
|
|
144
|
+ QCOMPARE(v.getX(), x + x2);
|
|
145
|
+ QCOMPARE(v.getY(), y + y2);
|
|
146
|
+ QCOMPARE(v.getZ(), z + z2);
|
|
147
|
+}
|
|
148
|
+
|
|
149
|
+void TestVector3D::add1Op()
|
|
150
|
+{
|
|
151
|
+ double x = 1.42, y = 2.0, z = 3.0, x2 = 0.24, y2 = 24.0, z2 = 42.0;
|
|
152
|
+ Vector3D v1(x, y, z);
|
|
153
|
+ Vector3D v2(x2, y2, z2);
|
|
154
|
+ Vector3D v = v1 + v2;
|
|
155
|
+
|
|
156
|
+ QCOMPARE(v.getX(), x + x2);
|
|
157
|
+ QCOMPARE(v.getY(), y + y2);
|
|
158
|
+ QCOMPARE(v.getZ(), z + z2);
|
|
159
|
+
|
|
160
|
+ QCOMPARE(v1.getX(), x);
|
|
161
|
+ QCOMPARE(v1.getY(), y);
|
|
162
|
+ QCOMPARE(v1.getZ(), z);
|
|
163
|
+
|
|
164
|
+ QCOMPARE(v2.getX(), x2);
|
|
165
|
+ QCOMPARE(v2.getY(), y2);
|
|
166
|
+ QCOMPARE(v2.getZ(), z2);
|
|
167
|
+}
|
|
168
|
+
|
|
169
|
+void TestVector3D::add2()
|
|
170
|
+{
|
|
171
|
+ double x = 1.42, y = 2.0, z = 3.0, m = 0.24;
|
|
172
|
+ Vector3D v(x, y, z);
|
|
173
|
+ v.add(m);
|
|
174
|
+ QCOMPARE(v.getX(), x + m);
|
|
175
|
+ QCOMPARE(v.getY(), y + m);
|
|
176
|
+ QCOMPARE(v.getZ(), z + m);
|
|
177
|
+}
|
|
178
|
+
|
|
179
|
+void TestVector3D::add2Op()
|
|
180
|
+{
|
|
181
|
+ double x = 1.42, y = 2.0, z = 3.0, m = 0.24;
|
|
182
|
+ Vector3D v1(x, y, z);
|
|
183
|
+ Vector3D v = v1 + m;
|
|
184
|
+
|
|
185
|
+ QCOMPARE(v.getX(), x + m);
|
|
186
|
+ QCOMPARE(v.getY(), y + m);
|
|
187
|
+ QCOMPARE(v.getZ(), z + m);
|
|
188
|
+
|
|
189
|
+ QCOMPARE(v1.getX(), x);
|
|
190
|
+ QCOMPARE(v1.getY(), y);
|
|
191
|
+ QCOMPARE(v1.getZ(), z);
|
|
192
|
+}
|
|
193
|
+
|
|
194
|
+void TestVector3D::add3Op()
|
|
195
|
+{
|
|
196
|
+ double x = 1.42, y = 2.0, z = 3.0;
|
|
197
|
+ Vector3D v1(x, y, z);
|
|
198
|
+ Vector3D v = +v1;
|
|
199
|
+
|
|
200
|
+ QCOMPARE(v.getX(), x);
|
|
201
|
+ QCOMPARE(v.getY(), y);
|
|
202
|
+ QCOMPARE(v.getZ(), z);
|
|
203
|
+
|
|
204
|
+ QCOMPARE(v1.getX(), x);
|
|
205
|
+ QCOMPARE(v1.getY(), y);
|
|
206
|
+ QCOMPARE(v1.getZ(), z);
|
|
207
|
+}
|
|
208
|
+
|
|
209
|
+void TestVector3D::sub1()
|
|
210
|
+{
|
|
211
|
+ double x = 1.42, y = 2.0, z = 3.0, x2 = 0.24, y2 = 24.0, z2 = 42.0;
|
|
212
|
+ Vector3D v(x, y, z);
|
|
213
|
+ v.sub(x2, y2, z2);
|
|
214
|
+ QCOMPARE(v.getX(), x - x2);
|
|
215
|
+ QCOMPARE(v.getY(), y - y2);
|
|
216
|
+ QCOMPARE(v.getZ(), z - z2);
|
|
217
|
+}
|
|
218
|
+
|
|
219
|
+void TestVector3D::sub1Op()
|
|
220
|
+{
|
|
221
|
+ double x = 1.42, y = 2.0, z = 3.0, x2 = 0.24, y2 = 24.0, z2 = 42.0;
|
|
222
|
+ Vector3D v1(x, y, z);
|
|
223
|
+ Vector3D v2(x2, y2, z2);
|
|
224
|
+ Vector3D v = v1 - v2;
|
|
225
|
+
|
|
226
|
+ QCOMPARE(v.getX(), x - x2);
|
|
227
|
+ QCOMPARE(v.getY(), y - y2);
|
|
228
|
+ QCOMPARE(v.getZ(), z - z2);
|
|
229
|
+
|
|
230
|
+ QCOMPARE(v1.getX(), x);
|
|
231
|
+ QCOMPARE(v1.getY(), y);
|
|
232
|
+ QCOMPARE(v1.getZ(), z);
|
|
233
|
+
|
|
234
|
+ QCOMPARE(v2.getX(), x2);
|
|
235
|
+ QCOMPARE(v2.getY(), y2);
|
|
236
|
+ QCOMPARE(v2.getZ(), z2);
|
|
237
|
+}
|
|
238
|
+
|
|
239
|
+void TestVector3D::sub2()
|
|
240
|
+{
|
|
241
|
+ double x = 1.42, y = 2.0, z = 3.0, m = 0.24;
|
|
242
|
+ Vector3D v(x, y, z);
|
|
243
|
+ v.sub(m);
|
|
244
|
+ QCOMPARE(v.getX(), x - m);
|
|
245
|
+ QCOMPARE(v.getY(), y - m);
|
|
246
|
+ QCOMPARE(v.getZ(), z - m);
|
|
247
|
+}
|
|
248
|
+
|
|
249
|
+void TestVector3D::sub2Op()
|
|
250
|
+{
|
|
251
|
+ double x = 1.42, y = 2.0, z = 3.0, m = 0.24;
|
|
252
|
+ Vector3D v1(x, y, z);
|
|
253
|
+ Vector3D v = v1 - m;
|
|
254
|
+
|
|
255
|
+ QCOMPARE(v.getX(), x - m);
|
|
256
|
+ QCOMPARE(v.getY(), y - m);
|
|
257
|
+ QCOMPARE(v.getZ(), z - m);
|
|
258
|
+
|
|
259
|
+ QCOMPARE(v1.getX(), x);
|
|
260
|
+ QCOMPARE(v1.getY(), y);
|
|
261
|
+ QCOMPARE(v1.getZ(), z);
|
|
262
|
+}
|
|
263
|
+
|
|
264
|
+void TestVector3D::sub3Op()
|
|
265
|
+{
|
|
266
|
+ double x = 1.42, y = 2.0, z = 3.0;
|
|
267
|
+ Vector3D v1(x, y, z);
|
|
268
|
+ Vector3D v = -v1;
|
|
269
|
+
|
|
270
|
+ QCOMPARE(v.getX(), -x);
|
|
271
|
+ QCOMPARE(v.getY(), -y);
|
|
272
|
+ QCOMPARE(v.getZ(), -z);
|
|
273
|
+
|
|
274
|
+ QCOMPARE(v1.getX(), x);
|
|
275
|
+ QCOMPARE(v1.getY(), y);
|
|
276
|
+ QCOMPARE(v1.getZ(), z);
|
|
277
|
+}
|
|
278
|
+
|
43
|
279
|
void TestVector3D::mult()
|
44
|
280
|
{
|
45
|
281
|
double x = 1.42, y = 2.0, z = 3.0, m = 2.0;
|
|
@@ -50,6 +286,16 @@ void TestVector3D::mult()
|
50
|
286
|
QCOMPARE(v.getZ(), z * m);
|
51
|
287
|
}
|
52
|
288
|
|
|
289
|
+void TestVector3D::multOp()
|
|
290
|
+{
|
|
291
|
+ double x = 1.42, y = 2.0, z = 3.0, m = 2.0;
|
|
292
|
+ Vector3D v1(x, y, z);
|
|
293
|
+ Vector3D v = v1 * m;
|
|
294
|
+ QCOMPARE(v.getX(), x * m);
|
|
295
|
+ QCOMPARE(v.getY(), y * m);
|
|
296
|
+ QCOMPARE(v.getZ(), z * m);
|
|
297
|
+}
|
|
298
|
+
|
53
|
299
|
void TestVector3D::div()
|
54
|
300
|
{
|
55
|
301
|
double x = 1.42, y = 2.0, z = 3.0, m = 2.0;
|