0
|
1 |
// Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// e32test\buffer\t_graph.cpp
|
|
15 |
// Overview:
|
|
16 |
// Test the TPoint, TSize, TRect class.
|
|
17 |
// API Information:
|
|
18 |
// TPoint, TSize, TRect.
|
|
19 |
// Details:
|
|
20 |
// - Initialize some two-dimensional points in Cartesian co-ordinates with various
|
|
21 |
// positive, negative values. Add and subtract different initialized points and
|
|
22 |
// check that results are as expected.
|
|
23 |
// - Create some two-dimensional sizes, set with various positive, negative values.
|
|
24 |
// Add and subtract different initialized sizes and check that results are as expected.
|
|
25 |
// - Initialize some rectangles in different positions, set various widths, heights and
|
|
26 |
// sizes and verify that values are assigned as specified.
|
|
27 |
// - Move the rectangle by adding two-dimensional point offset, some x, y offset and check
|
|
28 |
// that it is as expected.
|
|
29 |
// - Resize, shrink, grow, rectangles by adding, subtracting some horizontal, vertical
|
|
30 |
// offset and verify that it is as expected.
|
|
31 |
// - Get the minimal rectangles which bounds one rectangle and the specified rectangles,
|
|
32 |
// assign it to the rectangles and check that it is as expected.
|
|
33 |
// - Assign some rectangles with different positions and test whether the rectangle is
|
|
34 |
// empty, overlaps as expected.
|
|
35 |
// - Get the area of intersection between one rectangle and the specified rectangle,
|
|
36 |
// assign it to the rectangle and verify that the assigned rectangle is not empty.
|
|
37 |
// - Create some rectangles, check that the rectangle's width and height have positive
|
|
38 |
// values, the rectangle is normalized, whether a point is located within the rectangle
|
|
39 |
// and is empty.
|
|
40 |
// - Create some rectangles, get the points at the centre of the rectangles and check that
|
|
41 |
// it is as expected.
|
|
42 |
// - Create some three-dimensional points in Cartesian co-ordinates with various
|
|
43 |
// positive, negative values. Add and subtract different initialized points and
|
|
44 |
// check that results are as expected.
|
|
45 |
// Platforms/Drives/Compatibility:
|
|
46 |
// All
|
|
47 |
// Assumptions/Requirement/Pre-requisites:
|
|
48 |
// Failures and causes:
|
|
49 |
// Base Port information:
|
|
50 |
//
|
|
51 |
//
|
|
52 |
|
|
53 |
#include <e32test.h>
|
|
54 |
|
|
55 |
LOCAL_D RTest test(_L("T_GRAPH"));
|
|
56 |
|
|
57 |
class TestTPoint
|
|
58 |
{
|
|
59 |
public:
|
|
60 |
TestTPoint(TInt x1,TInt y1,TInt x2,TInt y2,TInt x3,TInt y3,TInt x4,TInt y4);
|
|
61 |
void TestSet();
|
|
62 |
void TestAdd();
|
|
63 |
void TestSub();
|
|
64 |
void TestUnaryMinus();
|
|
65 |
private:
|
|
66 |
TInt iX1;
|
|
67 |
TInt iY1;
|
|
68 |
TInt iX2;
|
|
69 |
TInt iY2;
|
|
70 |
TInt iX3;
|
|
71 |
TInt iY3;
|
|
72 |
TInt iX4;
|
|
73 |
TInt iY4;
|
|
74 |
};
|
|
75 |
|
|
76 |
class TestTSize
|
|
77 |
{
|
|
78 |
public:
|
|
79 |
TestTSize(TInt wid1,TInt hgt1,TInt wid2,TInt hgt2,TInt wid3,TInt hgt3,TInt wid4,TInt hgt4);
|
|
80 |
void TestSet();
|
|
81 |
void TestAdd();
|
|
82 |
void TestSub();
|
|
83 |
void TestUnaryMinus();
|
|
84 |
private:
|
|
85 |
TInt iWidth1;
|
|
86 |
TInt iHeight1;
|
|
87 |
TInt iWidth2;
|
|
88 |
TInt iHeight2;
|
|
89 |
TInt iWidth3;
|
|
90 |
TInt iHeight3;
|
|
91 |
TInt iWidth4;
|
|
92 |
TInt iHeight4;
|
|
93 |
};
|
|
94 |
|
|
95 |
class TestTRect
|
|
96 |
{
|
|
97 |
public:
|
|
98 |
TestTRect(TInt tlx1,TInt tly1,TInt brx1,TInt bry1,
|
|
99 |
TInt tlx2,TInt tly2,TInt brx2,TInt bry2,
|
|
100 |
TInt tlx3,TInt tly3,TInt brx3,TInt bry3);
|
|
101 |
void TestSet();
|
|
102 |
void TestMove();
|
|
103 |
void TestResize();
|
|
104 |
void TestShrink();
|
|
105 |
void TestGrow();
|
|
106 |
void TestBoundingRect();
|
|
107 |
void TestIsEmpty();
|
|
108 |
void TestIntersects();
|
|
109 |
void TestIntersection();
|
|
110 |
void TestNormalize();
|
|
111 |
void TestContains();
|
|
112 |
void TestCenter();
|
|
113 |
private:
|
|
114 |
TInt iTlx1;
|
|
115 |
TInt iTly1;
|
|
116 |
TInt iBrx1;
|
|
117 |
TInt iBry1;
|
|
118 |
TInt iTlx2;
|
|
119 |
TInt iTly2;
|
|
120 |
TInt iBrx2;
|
|
121 |
TInt iBry2;
|
|
122 |
TInt iTlx3;
|
|
123 |
TInt iTly3;
|
|
124 |
TInt iBrx3;
|
|
125 |
TInt iBry3;
|
|
126 |
};
|
|
127 |
|
|
128 |
class TestTPoint3D
|
|
129 |
{
|
|
130 |
public:
|
|
131 |
TestTPoint3D(TInt x1,TInt y1,TInt z1,TInt x2,TInt y2,TInt z2,TInt x3,TInt y3,TInt z3,TInt x4,TInt y4,TInt z4);
|
|
132 |
void TestSet();
|
|
133 |
void TestAdd();
|
|
134 |
void TestSub();
|
|
135 |
void TestUnaryMinus();
|
|
136 |
private:
|
|
137 |
TInt iX1;
|
|
138 |
TInt iY1;
|
|
139 |
TInt iZ1;
|
|
140 |
TInt iX2;
|
|
141 |
TInt iY2;
|
|
142 |
TInt iZ2;
|
|
143 |
TInt iX3;
|
|
144 |
TInt iY3;
|
|
145 |
TInt iZ3;
|
|
146 |
TInt iX4;
|
|
147 |
TInt iY4;
|
|
148 |
TInt iZ4;
|
|
149 |
|
|
150 |
};
|
|
151 |
|
|
152 |
//////////////////////////////////////////////////////////////////////////////
|
|
153 |
// Point test code //
|
|
154 |
//////////////////////////////////////////////////////////////////////////////
|
|
155 |
|
|
156 |
TestTPoint::TestTPoint(TInt x1,TInt y1,TInt x2,TInt y2,TInt x3,TInt y3,TInt x4,TInt y4)
|
|
157 |
{
|
|
158 |
iX1=x1;
|
|
159 |
iY1=y1;
|
|
160 |
iX2=x2;
|
|
161 |
iY2=y2;
|
|
162 |
iX3=x3;
|
|
163 |
iY3=y3;
|
|
164 |
iX4=x4;
|
|
165 |
iY4=y4;
|
|
166 |
}
|
|
167 |
|
|
168 |
void TestTPoint::TestSet()
|
|
169 |
{
|
|
170 |
TSize s1(iX3,iY3);
|
|
171 |
TPoint p1(iX1,iY1);
|
|
172 |
TPoint p2(iX2,iY2);
|
|
173 |
TPoint p3;
|
|
174 |
TPoint p4;
|
|
175 |
|
|
176 |
test(p1.iX==iX1 && p1.iY==iY1);
|
|
177 |
test(p2.iX==iX2 && p2.iY==iY2);
|
|
178 |
test(p4.iX==0 && p4.iY==0);
|
|
179 |
|
|
180 |
p3.iX=iX3;
|
|
181 |
p3.iY=iY3;
|
|
182 |
test(p3.iX==iX3 && p3.iY==iY3);
|
|
183 |
test(p3.AsSize()==s1);
|
|
184 |
|
|
185 |
p4.SetXY(iX4,iY4);
|
|
186 |
test(p4.iX==iX4 && p4.iY==iY4);
|
|
187 |
|
|
188 |
p1=p4;
|
|
189 |
test(p1==p4);
|
|
190 |
test(p1.iX==p4.iX && p1.iY==p4.iY);
|
|
191 |
|
|
192 |
p3=p2;
|
|
193 |
test(p3==p2);
|
|
194 |
test(p3.iX==p2.iX && p3.iY==p2.iY);
|
|
195 |
|
|
196 |
p1=p4;
|
|
197 |
p1.iX++;
|
|
198 |
test(p1!=p4);
|
|
199 |
p1=p4;
|
|
200 |
p1.iY++;
|
|
201 |
test(p1!=p4);
|
|
202 |
}
|
|
203 |
|
|
204 |
void TestTPoint::TestAdd()
|
|
205 |
{
|
|
206 |
TSize s1(iX3,iY3);
|
|
207 |
TPoint p1(iX1,iY1);
|
|
208 |
TPoint p2(iX2,iY2);
|
|
209 |
TPoint p3(iX3,iY3);
|
|
210 |
TPoint p4(iX4,iY4);
|
|
211 |
TPoint px;
|
|
212 |
|
|
213 |
p1+=p2;
|
|
214 |
test(p1.iX==(p2.iX+iX1) && p1.iY==(p2.iY+iY1));
|
|
215 |
px=p3=p1+p2;
|
|
216 |
test(p3.iX==(p1.iX+p2.iX) && p3.iY==(p1.iY+p2.iY));
|
|
217 |
test(p3==(p1+p2));
|
|
218 |
test(px==p3);
|
|
219 |
px=p4+=p1;
|
|
220 |
test(p4.iX==(p1.iX+iX4) && p4.iY==(p1.iY+iY4));
|
|
221 |
test(px==p4);
|
|
222 |
|
|
223 |
px=p1;
|
|
224 |
p1+=s1;
|
|
225 |
test(p1.iX==(px.iX+s1.iWidth) && p1.iY==(px.iY+s1.iHeight));
|
|
226 |
p2=px+s1;
|
|
227 |
test(p2==p1);
|
|
228 |
}
|
|
229 |
|
|
230 |
void TestTPoint::TestSub()
|
|
231 |
{
|
|
232 |
TSize s1(iX3,iY3);
|
|
233 |
TPoint p1(iX1,iY1);
|
|
234 |
TPoint p2(iX2,iY2);
|
|
235 |
TPoint p3(iX3,iY3);
|
|
236 |
TPoint p4(iX4,iY4);
|
|
237 |
TPoint px;
|
|
238 |
|
|
239 |
p1-=p2;
|
|
240 |
test(p1.iX==(iX1-p2.iX) && p1.iY==(iY1-p2.iY));
|
|
241 |
px=p3=p1-p2;
|
|
242 |
test(p3.iX==(p1.iX-p2.iX) && p3.iY==(p1.iY-p2.iY));
|
|
243 |
test(p3==(p1-p2));
|
|
244 |
test(px==p3);
|
|
245 |
px=p4-=p1;
|
|
246 |
test(p4.iX==(iX4-p1.iX) && p4.iY==(iY4-p1.iY));
|
|
247 |
test(px==p4);
|
|
248 |
|
|
249 |
px=p1;
|
|
250 |
p1-=s1;
|
|
251 |
test(p1.iX==(px.iX-s1.iWidth) && p1.iY==(px.iY-s1.iHeight));
|
|
252 |
p2=px-s1;
|
|
253 |
test(p2==p1);
|
|
254 |
}
|
|
255 |
|
|
256 |
void TestTPoint::TestUnaryMinus()
|
|
257 |
{
|
|
258 |
TPoint p1(iX1,iY1);
|
|
259 |
TPoint p2(iX2,iY2);
|
|
260 |
TPoint p3(iX3,iY3);
|
|
261 |
TPoint p4(iX4,iY4);
|
|
262 |
|
|
263 |
TPoint p=-p1;
|
|
264 |
test (p==TPoint(-iX1,-iY1));
|
|
265 |
p=-p2;
|
|
266 |
test (p==TPoint(-iX2,-iY2));
|
|
267 |
p=-p3;
|
|
268 |
test (p==TPoint(-iX3,-iY3));
|
|
269 |
p=-p4;
|
|
270 |
test (p==TPoint(-iX4,-iY4));
|
|
271 |
}
|
|
272 |
|
|
273 |
//////////////////////////////////////////////////////////////////////////////
|
|
274 |
// Size test code //
|
|
275 |
//////////////////////////////////////////////////////////////////////////////
|
|
276 |
|
|
277 |
TestTSize::TestTSize(TInt x1,TInt y1,TInt x2,TInt y2,TInt x3,TInt y3,TInt x4,TInt y4)
|
|
278 |
{
|
|
279 |
iWidth1=x1;
|
|
280 |
iHeight1=y1;
|
|
281 |
iWidth2=x2;
|
|
282 |
iHeight2=y2;
|
|
283 |
iWidth3=x3;
|
|
284 |
iHeight3=y3;
|
|
285 |
iWidth4=x4;
|
|
286 |
iHeight4=y4;
|
|
287 |
}
|
|
288 |
|
|
289 |
void TestTSize::TestSet()
|
|
290 |
{
|
|
291 |
TPoint p1(iWidth3,iHeight3);
|
|
292 |
TSize s1(iWidth1,iHeight1);
|
|
293 |
TSize s2(iWidth2,iHeight2);
|
|
294 |
TSize s3;
|
|
295 |
TSize s4;
|
|
296 |
|
|
297 |
test(s1.iWidth==iWidth1 && s1.iHeight==iHeight1);
|
|
298 |
test(s2.iWidth==iWidth2 && s2.iHeight==iHeight2);
|
|
299 |
test(s4.iWidth==0 && s4.iHeight==0);
|
|
300 |
|
|
301 |
s3.iWidth=iWidth3;
|
|
302 |
s3.iHeight=iHeight3;
|
|
303 |
test(s3.iWidth==iWidth3 && s3.iHeight==iHeight3);
|
|
304 |
test(s3.AsPoint()==p1);
|
|
305 |
|
|
306 |
s4.SetSize(iWidth4,iHeight4);
|
|
307 |
test(s4.iWidth==iWidth4 && s4.iHeight==iHeight4);
|
|
308 |
|
|
309 |
s1=s4;
|
|
310 |
test(s1==s4);
|
|
311 |
test(s1.iWidth==s4.iWidth && s1.iHeight==s4.iHeight);
|
|
312 |
s3=s2;
|
|
313 |
test(s3==s2);
|
|
314 |
test(s3.iWidth==s2.iWidth && s3.iHeight==s2.iHeight);
|
|
315 |
|
|
316 |
s1=s4;
|
|
317 |
s1.iWidth++;
|
|
318 |
test(s1!=s4);
|
|
319 |
s1=s4;
|
|
320 |
s1.iHeight++;
|
|
321 |
test(s1!=s4);
|
|
322 |
}
|
|
323 |
|
|
324 |
void TestTSize::TestAdd()
|
|
325 |
{
|
|
326 |
TPoint p1(iWidth3,iHeight3);
|
|
327 |
TSize s1(iWidth1,iHeight1);
|
|
328 |
TSize s2(iWidth2,iHeight2);
|
|
329 |
TSize s3(iWidth3,iHeight3);
|
|
330 |
TSize s4(iWidth4,iHeight4);
|
|
331 |
TSize sx;
|
|
332 |
|
|
333 |
s1+=s2;
|
|
334 |
test(s1.iWidth==(s2.iWidth+iWidth1) && s1.iHeight==(s2.iHeight+iHeight1));
|
|
335 |
sx=s3=s1+s2;
|
|
336 |
test(s3.iWidth==(s1.iWidth+s2.iWidth) && s3.iHeight==(s1.iHeight+s2.iHeight));
|
|
337 |
test(s3==(s1+s2));
|
|
338 |
test(sx==s3);
|
|
339 |
sx=s4+=s1;
|
|
340 |
test(s4.iWidth==(s1.iWidth+iWidth4) && s4.iHeight==(s1.iHeight+iHeight4));
|
|
341 |
test(sx==s4);
|
|
342 |
|
|
343 |
sx=s1;
|
|
344 |
s1+=p1;
|
|
345 |
test(s1.iWidth==(sx.iWidth+p1.iX) && s1.iHeight==(sx.iHeight+p1.iY));
|
|
346 |
s2=sx+p1;
|
|
347 |
test(s1==s2);
|
|
348 |
}
|
|
349 |
|
|
350 |
void TestTSize::TestSub()
|
|
351 |
{
|
|
352 |
TPoint p1(iWidth3,iHeight3);
|
|
353 |
TSize s1(iWidth1,iHeight1);
|
|
354 |
TSize s2(iWidth2,iHeight2);
|
|
355 |
TSize s3(iWidth3,iHeight3);
|
|
356 |
TSize s4(iWidth4,iHeight4);
|
|
357 |
TSize sx;
|
|
358 |
|
|
359 |
s1-=s2;
|
|
360 |
test(s1.iWidth==(iWidth1-s2.iWidth) && s1.iHeight==(iHeight1-s2.iHeight));
|
|
361 |
sx=s3=s1-s2;
|
|
362 |
test(s3.iWidth==(s1.iWidth-s2.iWidth) && s3.iHeight==(s1.iHeight-s2.iHeight));
|
|
363 |
test(s3==(s1-s2));
|
|
364 |
test(sx==s3);
|
|
365 |
sx=s4-=s1;
|
|
366 |
test(s4.iWidth==(iWidth4-s1.iWidth) && s4.iHeight==(iHeight4-s1.iHeight));
|
|
367 |
test(sx==s4);
|
|
368 |
|
|
369 |
sx=s1;
|
|
370 |
s1-=p1;
|
|
371 |
test(s1.iWidth==(sx.iWidth-p1.iX) && s1.iHeight==(sx.iHeight-p1.iY));
|
|
372 |
s2=sx-p1;
|
|
373 |
test(s1==s2);
|
|
374 |
}
|
|
375 |
|
|
376 |
void TestTSize::TestUnaryMinus()
|
|
377 |
{
|
|
378 |
TSize s1(iWidth1,iHeight1);
|
|
379 |
TSize s2(iWidth2,iHeight2);
|
|
380 |
TSize s3(iWidth3,iHeight3);
|
|
381 |
TSize s4(iWidth4,iHeight4);
|
|
382 |
|
|
383 |
TSize s=-s1;
|
|
384 |
test (s==TSize(-iWidth1,-iHeight1));
|
|
385 |
s=-s2;
|
|
386 |
test (s==TSize(-iWidth2,-iHeight2));
|
|
387 |
s=-s3;
|
|
388 |
test (s==TSize(-iWidth3,-iHeight3));
|
|
389 |
s=-s4;
|
|
390 |
test (s==TSize(-iWidth4,-iHeight4));
|
|
391 |
}
|
|
392 |
|
|
393 |
//////////////////////////////////////////////////////////////////////////////
|
|
394 |
// Rectangle test code //
|
|
395 |
//////////////////////////////////////////////////////////////////////////////
|
|
396 |
|
|
397 |
TestTRect::TestTRect(TInt tlx1,TInt tly1,TInt brx1,TInt bry1,
|
|
398 |
TInt tlx2,TInt tly2,TInt brx2,TInt bry2,
|
|
399 |
TInt tlx3,TInt tly3,TInt brx3,TInt bry3)
|
|
400 |
{
|
|
401 |
iTlx1=tlx1;
|
|
402 |
iTly1=tly1;
|
|
403 |
iBrx1=brx1;
|
|
404 |
iBry1=bry1;
|
|
405 |
iTlx2=tlx2;
|
|
406 |
iTly2=tly2;
|
|
407 |
iBrx2=brx2;
|
|
408 |
iBry2=bry2;
|
|
409 |
iTlx3=tlx3;
|
|
410 |
iTly3=tly3;
|
|
411 |
iBrx3=brx3;
|
|
412 |
iBry3=bry3;
|
|
413 |
}
|
|
414 |
|
|
415 |
void TestTRect::TestSet()
|
|
416 |
{
|
|
417 |
TSize s1(iTlx3,iTly3);
|
|
418 |
TPoint pTl(iTlx2,iTly2);
|
|
419 |
TPoint pBr(iBrx2,iBry2);
|
|
420 |
TRect r1(iTlx1,iTly1,iBrx1,iBry1);
|
|
421 |
TRect r2(pTl,pBr);
|
|
422 |
TRect r3;
|
|
423 |
TRect r4(pTl,s1);
|
|
424 |
|
|
425 |
test(r1.iTl.iX==iTlx1 && r1.iTl.iY==iTly1 && r1.iBr.iX==iBrx1 && r1.iBr.iY==iBry1);
|
|
426 |
test(r2.iTl.iX==iTlx2 && r2.iTl.iY==iTly2 && r2.iBr.iX==iBrx2 && r2.iBr.iY==iBry2);
|
|
427 |
test(r2.iTl==pTl && r2.iBr==pBr);
|
|
428 |
test(r3.iTl.iX==0 && r3.iTl.iY==0 && r3.iBr.iX==0 && r3.iBr.iY==0);
|
|
429 |
test(r4.iTl==pTl && r4.iBr.iX==(pTl.iX+s1.iWidth) && r4.iBr.iY==(pTl.iY+s1.iHeight));
|
|
430 |
|
|
431 |
r3.iTl.iX=iTlx3;
|
|
432 |
r3.iTl.iY=iTly3;
|
|
433 |
r3.iBr.iX=iBrx3;
|
|
434 |
r3.iBr.iY=iBry3;
|
|
435 |
test(r3.iTl.iX==iTlx3 && r3.iTl.iY==iTly3 && r3.iBr.iX==iBrx3 && r3.iBr.iY==iBry3);
|
|
436 |
|
|
437 |
r1.SetRect(iTlx2,iTly2,iBrx2,iBry2);
|
|
438 |
test(r1==r2);
|
|
439 |
|
|
440 |
r2=r3;
|
|
441 |
test(r2==r3);
|
|
442 |
|
|
443 |
pTl.SetXY(iTlx3,iTly3);
|
|
444 |
pBr.SetXY(iBrx3,iBry3);
|
|
445 |
r1.SetRect(pTl,pBr);
|
|
446 |
test(r1.iTl.iX==iTlx3 && r1.iTl.iY==iTly3 && r1.iBr.iX==iBrx3 && r1.iBr.iY==iBry3);
|
|
447 |
pTl.SetXY(iTlx2,iTly2);
|
|
448 |
r1.SetRect(pTl,s1);
|
|
449 |
test(r1==r4);
|
|
450 |
r4.iTl.iX++;
|
|
451 |
test(r1!=r4);
|
|
452 |
r4.iTl.iX--;
|
|
453 |
test(r1==r4);
|
|
454 |
r4.iTl.iY++;
|
|
455 |
test(r1!=r4);
|
|
456 |
r4.iTl.iY--;
|
|
457 |
test(r1==r4);
|
|
458 |
r4.iBr.iX++;
|
|
459 |
test(r1!=r4);
|
|
460 |
r4.iBr.iX--;
|
|
461 |
test(r1==r4);
|
|
462 |
r4.iBr.iY++;
|
|
463 |
test(r1!=r4);
|
|
464 |
|
|
465 |
r4=TRect(0,0,0,0);
|
|
466 |
r4.SetWidth(r1.Size().iWidth);
|
|
467 |
test(r1.Size().iWidth==r4.Size().iWidth);
|
|
468 |
test(r4.Size().iHeight==0);
|
|
469 |
|
|
470 |
r4.SetHeight(r1.Size().iHeight);
|
|
471 |
test(r1.Size().iHeight==r4.Size().iHeight);
|
|
472 |
test(r1.Size().iWidth==r4.Size().iWidth);
|
|
473 |
|
|
474 |
r4=TRect(0,0,0,0);
|
|
475 |
r4.SetSize(r1.Size());
|
|
476 |
test(r1.Size()==r4.Size());
|
|
477 |
}
|
|
478 |
|
|
479 |
void TestTRect::TestMove()
|
|
480 |
{
|
|
481 |
TPoint offs(iTlx2,iTly2);
|
|
482 |
TRect r1(iTlx1,iTly1,iBrx1,iBry1);
|
|
483 |
TRect rCheck,rTest;
|
|
484 |
|
|
485 |
rCheck=r1;
|
|
486 |
rCheck.iTl+=offs;
|
|
487 |
rCheck.iBr+=offs;
|
|
488 |
|
|
489 |
rTest=r1;
|
|
490 |
rTest.Move(offs);
|
|
491 |
test(rTest==rCheck);
|
|
492 |
|
|
493 |
rTest=r1;
|
|
494 |
rTest.Move(offs.iX,offs.iY);
|
|
495 |
test(rTest==rCheck);
|
|
496 |
}
|
|
497 |
|
|
498 |
void TestTRect::TestResize()
|
|
499 |
{
|
|
500 |
TSize resize(iTlx1,iTly1);
|
|
501 |
TRect rTest(iTlx2,iTly2,iBrx2,iBry2);
|
|
502 |
TRect rCheck;
|
|
503 |
|
|
504 |
rCheck=rTest;
|
|
505 |
rTest.Resize(resize);
|
|
506 |
rCheck.iBr+=resize;
|
|
507 |
test(rTest==rCheck);
|
|
508 |
}
|
|
509 |
|
|
510 |
void TestTRect::TestShrink()
|
|
511 |
{
|
|
512 |
TSize shrink(iTlx3,iTly3);
|
|
513 |
TRect r2(iTlx2,iTly2,iBrx2,iBry2);
|
|
514 |
TRect rCheck,rTest;
|
|
515 |
|
|
516 |
rCheck=r2;
|
|
517 |
rCheck.iTl+=shrink;
|
|
518 |
rCheck.iBr-=shrink;
|
|
519 |
|
|
520 |
rTest=r2;
|
|
521 |
rTest.Shrink(shrink);
|
|
522 |
test(rTest==rCheck);
|
|
523 |
|
|
524 |
rTest=r2;
|
|
525 |
rTest.Shrink(shrink.iWidth,shrink.iHeight);
|
|
526 |
test(rTest==rCheck);
|
|
527 |
}
|
|
528 |
|
|
529 |
void TestTRect::TestGrow()
|
|
530 |
{
|
|
531 |
TSize grow(iTlx3,iTly3);
|
|
532 |
TRect r2(iTlx2,iTly2,iBrx2,iBry2);
|
|
533 |
TRect rCheck,rTest;
|
|
534 |
|
|
535 |
rCheck=r2;
|
|
536 |
rCheck.iTl-=grow;
|
|
537 |
rCheck.iBr+=grow;
|
|
538 |
|
|
539 |
rTest=r2;
|
|
540 |
rTest.Grow(grow.iWidth,grow.iHeight);
|
|
541 |
test(rTest==rCheck);
|
|
542 |
|
|
543 |
rTest=r2;
|
|
544 |
rTest.Grow(grow);
|
|
545 |
test(rTest==rCheck);
|
|
546 |
}
|
|
547 |
|
|
548 |
void TestTRect::TestBoundingRect()
|
|
549 |
{
|
|
550 |
TRect r1(iTlx1,iTly1,iBrx1,iBry1);
|
|
551 |
TRect r2(iTlx2,iTly2,iBrx2,iBry2);
|
|
552 |
TRect r3(iTlx3,iTly3,iBrx3,iBry3);
|
|
553 |
TRect rCheck,rTest;
|
|
554 |
|
|
555 |
rCheck=r1;
|
|
556 |
rCheck.iTl.iX=Min(r1.iTl.iX,r2.iTl.iX);
|
|
557 |
rCheck.iTl.iY=Min(r1.iTl.iY,r2.iTl.iY);
|
|
558 |
rCheck.iBr.iX=Max(r1.iBr.iX,r2.iBr.iX);
|
|
559 |
rCheck.iBr.iY=Max(r1.iBr.iY,r2.iBr.iY);
|
|
560 |
rTest=r1;
|
|
561 |
rTest.BoundingRect(r2);
|
|
562 |
test(rTest==rCheck);
|
|
563 |
|
|
564 |
rCheck=r1;
|
|
565 |
rCheck.iTl.iX=Min(r1.iTl.iX,r3.iTl.iX);
|
|
566 |
rCheck.iTl.iY=Min(r1.iTl.iY,r3.iTl.iY);
|
|
567 |
rCheck.iBr.iX=Max(r1.iBr.iX,r3.iBr.iX);
|
|
568 |
rCheck.iBr.iY=Max(r1.iBr.iY,r3.iBr.iY);
|
|
569 |
rTest=r1;
|
|
570 |
rTest.BoundingRect(r3);
|
|
571 |
test(rTest==rCheck);
|
|
572 |
}
|
|
573 |
|
|
574 |
void TestTRect::TestIsEmpty()
|
|
575 |
{
|
|
576 |
TRect f1(0,0,1,1); // f? should return false
|
|
577 |
TRect f2(-1,-1,0,0);
|
|
578 |
TRect f3(-2,-2,-1,-1);
|
|
579 |
TRect t1(0,0,1,0); // t? should return true
|
|
580 |
TRect t2(0,0,0,1);
|
|
581 |
TRect t3(0,0,-1,1);
|
|
582 |
TRect t4(0,0,1,-1);
|
|
583 |
TRect t5(-2,-2,-1,-3);
|
|
584 |
TRect t6(-2,-2,-3,-1);
|
|
585 |
|
|
586 |
test(f1.IsEmpty()==FALSE);
|
|
587 |
test(f2.IsEmpty()==FALSE);
|
|
588 |
test(f3.IsEmpty()==FALSE);
|
|
589 |
test(t1.IsEmpty()==TRUE);
|
|
590 |
test(t2.IsEmpty()==TRUE);
|
|
591 |
test(t3.IsEmpty()==TRUE);
|
|
592 |
test(t4.IsEmpty()==TRUE);
|
|
593 |
test(t5.IsEmpty()==TRUE);
|
|
594 |
test(t6.IsEmpty()==TRUE);
|
|
595 |
}
|
|
596 |
|
|
597 |
void TestTRect::TestIntersects()
|
|
598 |
{
|
|
599 |
test(TRect(-5,-10,5,10).Intersects(TRect(4,-10,10,10))==TRUE);
|
|
600 |
test(TRect(-5,-10,5,10).Intersects(TRect(5,-10,10,10))==FALSE);
|
|
601 |
test(TRect(-5,-10,5,10).Intersects(TRect(6,-10,10,10))==FALSE);
|
|
602 |
test(TRect(-5,-10,5,10).Intersects(TRect(-5, 9, 5,20))==TRUE);
|
|
603 |
test(TRect(-5,-10,5,10).Intersects(TRect(-5,10, 5,20))==FALSE);
|
|
604 |
test(TRect(-5,-10,5,10).Intersects(TRect(-5,11, 5,20))==FALSE);
|
|
605 |
//
|
|
606 |
test(TRect(4,-10,10,10).Intersects(TRect(-5,-10,5,10))==TRUE);
|
|
607 |
test(TRect(5,-10,10,10).Intersects(TRect(-5,-10,5,10))==FALSE);
|
|
608 |
test(TRect(6,-10,10,10).Intersects(TRect(-5,-10,5,10))==FALSE);
|
|
609 |
test(TRect(-5, 9, 5,20).Intersects(TRect(-5,-10,5,10))==TRUE);
|
|
610 |
test(TRect(-5,10, 5,20).Intersects(TRect(-5,-10,5,10))==FALSE);
|
|
611 |
test(TRect(-5,11, 5,20).Intersects(TRect(-5,-10,5,10))==FALSE);
|
|
612 |
// Empty rects, should all return FALSE
|
|
613 |
test(TRect(0,11, 5,11).Intersects(TRect(0,0,5,20))==FALSE);
|
|
614 |
test(TRect(1,10, 1,11).Intersects(TRect(0,0,5,20))==FALSE);
|
|
615 |
test(TRect(5,11, 5,11).Intersects(TRect(0,0,5,20))==FALSE);
|
|
616 |
}
|
|
617 |
|
|
618 |
void TestTRect::TestIntersection()
|
|
619 |
{
|
|
620 |
TRect r1(iTlx1,iTly1,iBrx1,iBry1);
|
|
621 |
TRect r2(iTlx2,iTly2,iBrx2,iBry2);
|
|
622 |
TRect r3(iTlx3,iTly3,iBrx3,iBry3);
|
|
623 |
TRect rCheck,rTest;
|
|
624 |
|
|
625 |
rCheck=r1;
|
|
626 |
rCheck.iTl.iX=Max(r1.iTl.iX,r2.iTl.iX);
|
|
627 |
rCheck.iTl.iY=Max(r1.iTl.iY,r2.iTl.iY);
|
|
628 |
rCheck.iBr.iX=Min(r1.iBr.iX,r2.iBr.iX);
|
|
629 |
rCheck.iBr.iY=Min(r1.iBr.iY,r2.iBr.iY);
|
|
630 |
rTest=r1;
|
|
631 |
rTest.Intersection(r2);
|
|
632 |
if (!rCheck.IsEmpty())
|
|
633 |
test(rTest==rCheck);
|
|
634 |
|
|
635 |
rCheck=r1;
|
|
636 |
rCheck.iTl.iX=Max(r1.iTl.iX,r3.iTl.iX);
|
|
637 |
rCheck.iTl.iY=Max(r1.iTl.iY,r3.iTl.iY);
|
|
638 |
rCheck.iBr.iX=Min(r1.iBr.iX,r3.iBr.iX);
|
|
639 |
rCheck.iBr.iY=Min(r1.iBr.iY,r3.iBr.iY);
|
|
640 |
rTest=r1;
|
|
641 |
rTest.Intersection(r3);
|
|
642 |
if (!rCheck.IsEmpty())
|
|
643 |
test(rTest==rCheck);
|
|
644 |
|
|
645 |
rCheck=r3;
|
|
646 |
rCheck.iTl.iX=Max(r3.iTl.iX,r2.iTl.iX);
|
|
647 |
rCheck.iTl.iY=Max(r3.iTl.iY,r2.iTl.iY);
|
|
648 |
rCheck.iBr.iX=Min(r3.iBr.iX,r2.iBr.iX);
|
|
649 |
rCheck.iBr.iY=Min(r3.iBr.iY,r2.iBr.iY);
|
|
650 |
rTest=r3;
|
|
651 |
rTest.Intersection(r2);
|
|
652 |
if (!rCheck.IsEmpty())
|
|
653 |
test(rTest==rCheck);
|
|
654 |
}
|
|
655 |
|
|
656 |
void TestTRect::TestNormalize()
|
|
657 |
{
|
|
658 |
TUint i;
|
|
659 |
TInt tmp;
|
|
660 |
TRect a[]={TRect(0,0,1,1),TRect(-1,0,0,-1),TRect(-2,2,-1,1),TRect(10,2,1,0),
|
|
661 |
TRect(-10,-20,-2,-1),TRect(0,0,10,0),TRect(20,1,20,2),TRect(10,10,10,10)};
|
|
662 |
TBool aIsNormalized[]={TRUE,FALSE,FALSE,FALSE,TRUE,TRUE,TRUE,TRUE};
|
|
663 |
TRect tst,check;
|
|
664 |
|
|
665 |
for(i=0;i<(sizeof(a)/sizeof(a[0]));i++)
|
|
666 |
{
|
|
667 |
check=tst=a[i];
|
|
668 |
if (check.iTl.iX>check.iBr.iX)
|
|
669 |
{
|
|
670 |
tmp=check.iBr.iX;
|
|
671 |
check.iBr.iX=check.iTl.iX;
|
|
672 |
check.iTl.iX=tmp;
|
|
673 |
}
|
|
674 |
if (check.iTl.iY>check.iBr.iY)
|
|
675 |
{
|
|
676 |
tmp=check.iBr.iY;
|
|
677 |
check.iBr.iY=check.iTl.iY;
|
|
678 |
check.iTl.iY=tmp;
|
|
679 |
}
|
|
680 |
test(tst.IsNormalized()==aIsNormalized[i]);
|
|
681 |
tst.Normalize();
|
|
682 |
test(tst.IsNormalized()==TRUE);
|
|
683 |
test(tst==check);
|
|
684 |
}
|
|
685 |
}
|
|
686 |
|
|
687 |
void TestTRect::TestContains()
|
|
688 |
{
|
|
689 |
TPoint tl1(iTlx1,iTly1);
|
|
690 |
TPoint br1(iBrx1,iBry1);
|
|
691 |
TPoint tl2(iTlx2,iTly2);
|
|
692 |
TPoint br2(iBrx2,iBry2);
|
|
693 |
TPoint tl3(iTlx3,iTly3);
|
|
694 |
TPoint br3(iBrx3,iBry3);
|
|
695 |
TRect rect1(tl1,br1);
|
|
696 |
TRect rect2(tl2,br2);
|
|
697 |
TRect rect3(tl3,br3);
|
|
698 |
|
|
699 |
rect1.Normalize();
|
|
700 |
rect2.Normalize();
|
|
701 |
rect3.Normalize();
|
|
702 |
test(rect1.IsEmpty() || rect1.Contains(rect1.iTl));
|
|
703 |
test(rect2.IsEmpty() || rect2.Contains(rect2.iTl));
|
|
704 |
test(rect3.IsEmpty() || rect3.Contains(rect3.iTl));
|
|
705 |
test(!rect1.Contains(rect1.iBr));
|
|
706 |
test(!rect2.Contains(rect2.iBr));
|
|
707 |
test(!rect3.Contains(rect3.iBr));
|
|
708 |
TPoint pnt;
|
|
709 |
pnt.SetXY(rect1.iTl.iX,rect1.iBr.iY);
|
|
710 |
test(!rect1.Contains(pnt));
|
|
711 |
pnt.SetXY(rect1.iBr.iX,rect1.iTl.iY);
|
|
712 |
test(!rect1.Contains(pnt));
|
|
713 |
pnt=rect2.iTl;
|
|
714 |
if (rect2.iBr.iX>(rect2.iTl.iX+1) && rect2.iBr.iY>(rect2.iTl.iY+1))
|
|
715 |
pnt+=TPoint(1,1);
|
|
716 |
test(rect2.Contains(pnt));
|
|
717 |
}
|
|
718 |
|
|
719 |
void TestTRect::TestCenter()
|
|
720 |
{
|
|
721 |
TRect rect[]={TRect(iTlx1,iTly1,iBrx1,iBry1),TRect(iTlx2,iTly2,iBrx2,iBry2),TRect(iTlx3,iTly3,iBrx3,iBry3)};
|
|
722 |
|
|
723 |
for(TUint i=0;i<(sizeof(rect)/sizeof(rect[0]));i++)
|
|
724 |
{
|
|
725 |
TRect& r=rect[i];
|
|
726 |
TPoint center((r.iBr.iX+r.iTl.iX)/2,(r.iBr.iY+r.iTl.iY)/2);
|
|
727 |
test(center==r.Center());
|
|
728 |
}
|
|
729 |
}
|
|
730 |
|
|
731 |
//////////////////////////////////////////////////////////////////////////////
|
|
732 |
// 3DPoint test code //
|
|
733 |
//////////////////////////////////////////////////////////////////////////////
|
|
734 |
TestTPoint3D::TestTPoint3D(TInt x1,TInt y1,TInt z1,TInt x2,TInt y2,TInt z2,TInt x3,TInt y3,TInt z3,TInt x4,TInt y4,TInt z4)
|
|
735 |
{
|
|
736 |
iX1=x1;
|
|
737 |
iY1=y1;
|
|
738 |
iZ1=z1;
|
|
739 |
iX2=x2;
|
|
740 |
iY2=y2;
|
|
741 |
iZ2=z2;
|
|
742 |
iX3=x3;
|
|
743 |
iY3=y3;
|
|
744 |
iZ3=z3;
|
|
745 |
iX4=x4;
|
|
746 |
iY4=y4;
|
|
747 |
iZ4=z4;
|
|
748 |
}
|
|
749 |
|
|
750 |
|
|
751 |
void TestTPoint3D::TestSet()
|
|
752 |
{
|
|
753 |
|
|
754 |
TPoint aPoint(iX3,iY3);
|
|
755 |
TPoint3D p3D1(iX1,iY1,iZ1);
|
|
756 |
TPoint3D p3D2(iX2,iY2,iZ2);
|
|
757 |
TPoint3D p3D3;
|
|
758 |
TPoint3D p3D4;
|
|
759 |
TPoint3D p3D5(aPoint);
|
|
760 |
|
|
761 |
test(p3D1.iX==iX1 && p3D1.iY==iY1 && p3D1.iZ==iZ1);
|
|
762 |
test(p3D2.iX==iX2 && p3D2.iY==iY2 && p3D2.iZ==iZ2);
|
|
763 |
test(p3D4.iX==0 && p3D4.iY==0 && p3D4.iZ==0);
|
|
764 |
|
|
765 |
p3D3.iX=iX3;
|
|
766 |
p3D3.iY=iY3;
|
|
767 |
p3D3.iZ=iZ3;
|
|
768 |
test(p3D3.iX==iX3 && p3D3.iY==iY3&& p3D3.iZ==iZ3);
|
|
769 |
test(p3D3.AsPoint()==aPoint);
|
|
770 |
test(p3D5.AsPoint()==p3D3.AsPoint());
|
|
771 |
|
|
772 |
|
|
773 |
p3D4.SetXYZ(iX4,iY4,iZ4);
|
|
774 |
test(p3D4.iX==iX4 && p3D4.iY==iY4);
|
|
775 |
|
|
776 |
p3D1=p3D4;
|
|
777 |
test(p3D1==p3D4);
|
|
778 |
test(p3D1.iX==p3D4.iX && p3D1.iY==p3D4.iY && p3D1.iZ==p3D4.iZ);
|
|
779 |
|
|
780 |
p3D3=p3D2;
|
|
781 |
test(p3D3==p3D2);
|
|
782 |
test(p3D3.iX==p3D2.iX && p3D3.iY==p3D2.iY && p3D3.iZ==p3D2.iZ);
|
|
783 |
|
|
784 |
p3D1=p3D4;
|
|
785 |
p3D1.iX++;
|
|
786 |
test(p3D1!=p3D4);
|
|
787 |
p3D1=p3D4;
|
|
788 |
p3D1.iY++;
|
|
789 |
test(p3D1!=p3D4);
|
|
790 |
}
|
|
791 |
|
|
792 |
|
|
793 |
void TestTPoint3D::TestAdd()
|
|
794 |
{
|
|
795 |
TPoint apoint(iX3,iY3);
|
|
796 |
TPoint3D p1(iX1,iY1,iZ1);
|
|
797 |
TPoint3D p2(iX2,iY2,iZ2);
|
|
798 |
TPoint3D p3(iX3,iY3,iZ3);
|
|
799 |
TPoint3D p4(iX4,iY4,iZ4);
|
|
800 |
TPoint3D px;
|
|
801 |
|
|
802 |
p1+=p2;
|
|
803 |
test(p1.iX==(p2.iX+iX1) && p1.iY==(p2.iY+iY1)&& p1.iZ==(p2.iZ+iZ1));
|
|
804 |
px=p3=p1+p2;
|
|
805 |
test(p3.iX==(p1.iX+p2.iX) && p3.iY==(p1.iY+p2.iY)&& p3.iZ==(p1.iZ+p2.iZ));
|
|
806 |
test(p3==(p1+p2));
|
|
807 |
test(px==p3);
|
|
808 |
px=p4+=p1;
|
|
809 |
test(p4.iX==(p1.iX+iX4) && p4.iY==(p1.iY+iY4)&& p4.iZ==(p1.iZ+iZ4));
|
|
810 |
test(px==p4);
|
|
811 |
px=p1;
|
|
812 |
p1+=apoint;
|
|
813 |
//TPoint has no Z co-ordinate
|
|
814 |
test(p1.iX==(px.iX+apoint.iX) && p1.iY==(px.iY+apoint.iY) &&p1.iZ==px.iZ);
|
|
815 |
p2=px+apoint;
|
|
816 |
test(p2==p1);
|
|
817 |
}
|
|
818 |
|
|
819 |
void TestTPoint3D::TestSub()
|
|
820 |
{
|
|
821 |
TPoint apoint(iX3,iY3);
|
|
822 |
TPoint3D p1(iX1,iY1,iZ1);
|
|
823 |
TPoint3D p2(iX2,iY2,iZ2);
|
|
824 |
TPoint3D p3(iX3,iY3,iZ3);
|
|
825 |
TPoint3D p4(iX4,iY4,iZ4);
|
|
826 |
TPoint3D px;
|
|
827 |
|
|
828 |
p1-=p2;
|
|
829 |
test(p1.iX==(iX1-p2.iX) && p1.iY==(iY1-p2.iY)&& p1.iZ==(iZ1-p2.iZ));
|
|
830 |
px=p3=p1-p2;
|
|
831 |
test(p3.iX==(p1.iX-p2.iX) && p3.iY==(p1.iY-p2.iY)&& p3.iZ==(p1.iZ-p2.iZ));
|
|
832 |
test(p3==(p1-p2));
|
|
833 |
test(px==p3);
|
|
834 |
px=p4-=p1;
|
|
835 |
test(p4.iX==(iX4-p1.iX) && p4.iY==(iY4-p1.iY)&& p4.iZ==(iZ4-p1.iZ));
|
|
836 |
test(px==p4);
|
|
837 |
|
|
838 |
px=p1;
|
|
839 |
p1-=apoint;
|
|
840 |
//TPoint has no Z co-ordinate
|
|
841 |
test(p1.iX==(px.iX-apoint.iX) && p1.iY==(px.iY-apoint.iY)&&p1.iZ==px.iZ);
|
|
842 |
p2=px-apoint;
|
|
843 |
test(p2==p1);
|
|
844 |
}
|
|
845 |
|
|
846 |
void TestTPoint3D::TestUnaryMinus()
|
|
847 |
{
|
|
848 |
TPoint3D p1(iX1,iY1,iZ1);
|
|
849 |
TPoint3D p2(iX2,iY2,iZ2);
|
|
850 |
TPoint3D p3(iX3,iY3,iZ3);
|
|
851 |
TPoint3D p4(iX4,iY4,iZ4);
|
|
852 |
TPoint3D p=-p1;
|
|
853 |
test (p==TPoint3D(-iX1,-iY1,-iZ1));
|
|
854 |
p=-p2;
|
|
855 |
test (p==TPoint3D(-iX2,-iY2,-iZ2));
|
|
856 |
p=-p3;
|
|
857 |
test (p==TPoint3D(-iX3,-iY3,-iZ3));
|
|
858 |
p=-p4;
|
|
859 |
test (p==TPoint3D(-iX4,-iY4,-iZ4));
|
|
860 |
}
|
|
861 |
|
|
862 |
//////////////////////////////////////////////////////////////////////////////
|
|
863 |
// Top level test code //
|
|
864 |
//////////////////////////////////////////////////////////////////////////////
|
|
865 |
|
|
866 |
LOCAL_C void test_point(TestTPoint t)
|
|
867 |
{
|
|
868 |
test.Start(_L("Setting values"));
|
|
869 |
t.TestSet();
|
|
870 |
test.Next(_L("Addition"));
|
|
871 |
t.TestAdd();
|
|
872 |
test.Next(_L("Subtraction"));
|
|
873 |
t.TestSub();
|
|
874 |
test.Next(_L("Unary minus"));
|
|
875 |
t.TestUnaryMinus();
|
|
876 |
test.End();
|
|
877 |
}
|
|
878 |
|
|
879 |
LOCAL_C void test_size(TestTSize t)
|
|
880 |
{
|
|
881 |
test.Start(_L("Setting values"));
|
|
882 |
t.TestSet();
|
|
883 |
test.Next(_L("Addition"));
|
|
884 |
t.TestAdd();
|
|
885 |
test.Next(_L("Subtraction"));
|
|
886 |
t.TestSub();
|
|
887 |
test.Next(_L("Unary minus"));
|
|
888 |
t.TestUnaryMinus();
|
|
889 |
test.End();
|
|
890 |
}
|
|
891 |
|
|
892 |
LOCAL_C void test_rect(TestTRect t)
|
|
893 |
{
|
|
894 |
test.Start(_L("Setting values"));
|
|
895 |
t.TestSet();
|
|
896 |
test.Next(_L("Offset"));
|
|
897 |
t.TestMove();
|
|
898 |
test.Next(_L("Resize"));
|
|
899 |
t.TestResize();
|
|
900 |
test.Next(_L("Grow"));
|
|
901 |
t.TestGrow();
|
|
902 |
test.Next(_L("Shrink"));
|
|
903 |
t.TestShrink();
|
|
904 |
test.Next(_L("BoundingRect"));
|
|
905 |
t.TestBoundingRect();
|
|
906 |
test.Next(_L("IsEmpty"));
|
|
907 |
t.TestIsEmpty();
|
|
908 |
test.Next(_L("Intersects"));
|
|
909 |
t.TestIntersects();
|
|
910 |
test.Next(_L("Intersection"));
|
|
911 |
t.TestIntersection();
|
|
912 |
test.Next(_L("Normalize"));
|
|
913 |
t.TestNormalize();
|
|
914 |
test.Next(_L("Contains"));
|
|
915 |
t.TestContains();
|
|
916 |
test.Next(_L("Center"));
|
|
917 |
t.TestCenter();
|
|
918 |
test.End();
|
|
919 |
}
|
|
920 |
|
|
921 |
|
|
922 |
LOCAL_C void test_3Dpoint(TestTPoint3D t)
|
|
923 |
{
|
|
924 |
test.Start(_L("Setting values"));
|
|
925 |
t.TestSet();
|
|
926 |
test.Next(_L("Addition"));
|
|
927 |
t.TestAdd();
|
|
928 |
test.Next(_L("Subtraction"));
|
|
929 |
t.TestSub();
|
|
930 |
test.Next(_L("Unary minus"));
|
|
931 |
t.TestUnaryMinus();
|
|
932 |
test.End();
|
|
933 |
}
|
|
934 |
|
|
935 |
GLDEF_C TInt E32Main()
|
|
936 |
{
|
|
937 |
//
|
|
938 |
|
|
939 |
|
|
940 |
test.Title();
|
|
941 |
//
|
|
942 |
// Test the TPoint type.
|
|
943 |
//
|
|
944 |
TestTPoint tp1(1,2, 3,5, 8,13, 20,33);
|
|
945 |
TestTPoint tp2(10,-12, -55,29, -222,-666, 0,0);
|
|
946 |
TestTPoint tp3(345678,10, -9,987654, -1234567,-9876543, 222222,33333);
|
|
947 |
TestTPoint tp4(-1,-2,-3,-4,-5,-6,-7,-8);
|
|
948 |
TestTPoint tp5(0,0, 1000000,0, 0,2000000, 3000000,4000000);
|
|
949 |
//
|
|
950 |
test.Start(_L("class TPoint 1"));
|
|
951 |
test_point(tp1);
|
|
952 |
test.Next(_L("class TPoint 2"));
|
|
953 |
test_point(tp2);
|
|
954 |
test.Next(_L("class TPoint 3"));
|
|
955 |
test_point(tp3);
|
|
956 |
test.Next(_L("class TPoint 4"));
|
|
957 |
test_point(tp4);
|
|
958 |
test.Next(_L("class TPoint 5"));
|
|
959 |
test_point(tp5);
|
|
960 |
//
|
|
961 |
// Test the TSize type.
|
|
962 |
//
|
|
963 |
TestTSize sp1(5,4, 9,5, 17,33, 44,75);
|
|
964 |
TestTSize sp2(12,-10, -29,55, -666,-222, 0,0);
|
|
965 |
TestTSize sp3(456789,20, -3,876543, -2345678,-8765432, 33333,11111);
|
|
966 |
TestTSize sp4(-1,-2,-3,-4,-5,-6,-7,-8);
|
|
967 |
TestTSize sp5(0,0, 2000000,0, 0,3000000, 1000000,6000000);
|
|
968 |
//
|
|
969 |
test.Next(_L("class TSize 1"));
|
|
970 |
test_size(sp1);
|
|
971 |
test.Next(_L("class TSize 2"));
|
|
972 |
test_size(sp2);
|
|
973 |
test.Next(_L("class TSize 3"));
|
|
974 |
test_size(sp3);
|
|
975 |
test.Next(_L("class TSize 4"));
|
|
976 |
test_size(sp4);
|
|
977 |
test.Next(_L("class TSize 5"));
|
|
978 |
test_size(sp5);
|
|
979 |
//
|
|
980 |
// TRect tests
|
|
981 |
//
|
|
982 |
TestTRect tr1(0,0,1,2, 10,20,14,19, 33,11,44,55);
|
|
983 |
TestTRect tr2(-10,-20,11,22, -100,-200,-90,-199, 3000,1100,-4400,-5500);
|
|
984 |
TestTRect tr3(0,0,0,0, 1,1,2,2, -1,-1,0,0);
|
|
985 |
//
|
|
986 |
test.Next(_L("class TRect 1"));
|
|
987 |
test_rect(tr1);
|
|
988 |
test.Next(_L("class TRect 2"));
|
|
989 |
test_rect(tr2);
|
|
990 |
test.Next(_L("class TRect 3"));
|
|
991 |
test_rect(tr3);
|
|
992 |
//
|
|
993 |
//
|
|
994 |
// Test the TPoint3D type.
|
|
995 |
//
|
|
996 |
TestTPoint3D t3dp1(1,2,3, 4,5,6, 7 ,8,9, 10,11,12);
|
|
997 |
TestTPoint3D t3dp2(28,-12,75, -55,-98, -222, -788,-666,-155, 0,0,0);
|
|
998 |
TestTPoint3D t3dp3(89823,-45,12121,-78454,345678,10, -9,987654, -1234567,-9876543, 222222,33333);
|
|
999 |
TestTPoint3D t3dp4(-12,-32,-53,-84,-95,-456,-467,-4658,-45,-908,-65,-908);
|
|
1000 |
TestTPoint3D t3dp5(0,0,0, 23,1000000,0,10677,-3,2000000, 3000000,4000000,501);
|
|
1001 |
|
|
1002 |
//
|
|
1003 |
test.Start(_L("class TPoint3D 1"));
|
|
1004 |
test_3Dpoint(t3dp1);
|
|
1005 |
test.Next(_L("class TPoint3D 2"));
|
|
1006 |
test_3Dpoint(t3dp2);
|
|
1007 |
test.Next(_L("class TPoint3D 3"));
|
|
1008 |
test_3Dpoint(t3dp3);
|
|
1009 |
test.Next(_L("class TPoint3D 4"));
|
|
1010 |
test_3Dpoint(t3dp4);
|
|
1011 |
test.Next(_L("class TPoint3D 5"));
|
|
1012 |
test_3Dpoint(t3dp5);
|
|
1013 |
//
|
|
1014 |
test.Printf(_L("T_GRAPH: TEST Successfully Completed \n"));
|
|
1015 |
test.End();
|
|
1016 |
test.Close();
|
|
1017 |
return(0);
|
|
1018 |
}
|
|
1019 |
|