|
1 // Copyright (c) 1996-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\math\t_r64.cpp |
|
15 // T_R64.CPP - Test routines for TReal64 |
|
16 // Also note that these tests do not generally include testing of special values. This is done |
|
17 // in T_R96 tests and conversions are tested thoroughly, so explicit tests are unnecessary here. |
|
18 // |
|
19 // |
|
20 |
|
21 #include "t_math.h" |
|
22 #include "t_vals.h" |
|
23 #include "t_real64.h" |
|
24 |
|
25 // Data for tests from T_R64DTA.cpp |
|
26 GLREF_D TReal64 addInput[]; |
|
27 GLREF_D TReal64 subInput[]; |
|
28 GLREF_D TReal64 multInput[]; |
|
29 GLREF_D TReal64 divInput[]; |
|
30 GLREF_D TReal64 divDenormalInput[]; |
|
31 GLREF_D TReal64 unaryInput[]; |
|
32 GLREF_D TReal64 incDecInput[]; |
|
33 GLREF_D TInt sizeAdd; |
|
34 GLREF_D TInt sizeSub; |
|
35 GLREF_D TInt sizeMult; |
|
36 GLREF_D TInt sizeDiv; |
|
37 GLREF_D TInt sizeDivDenormal; |
|
38 GLREF_D TInt sizeUnary; |
|
39 GLREF_D TInt sizeIncDec; |
|
40 |
|
41 #if defined (__WINS__) || defined (__X86__) |
|
42 // Functions from EMGCC64.CPP |
|
43 GLREF_C TReal64 __adddf3(TReal64 a1,TReal64 a2); |
|
44 GLREF_C TReal64 __subdf3(TReal64 a1,TReal64 a2); |
|
45 GLREF_C TReal64 __muldf3(TReal64 a1,TReal64 a2); |
|
46 GLREF_C TReal64 __divdf3(TReal64 a1,TReal64 a2); |
|
47 #endif |
|
48 |
|
49 // Special numbers for arithmetic tests |
|
50 GLDEF_D TReal64 endsInFour; |
|
51 GLDEF_D TReal64 arg1; |
|
52 GLDEF_D TReal64 arg2; |
|
53 GLDEF_D TReal64 arg3; |
|
54 GLDEF_D const TReal64 KMinDenormalTReal64=5E-324; |
|
55 GLDEF_D const TReal KNaNTReal=TReal(KNaNTReal64); |
|
56 GLDEF_D const TReal KPosInfTReal=TReal(KPosInfTReal64);; |
|
57 GLDEF_D const TReal KNegInfTReal=TReal(KNegInfTReal64);; |
|
58 GLDEF_D const TReal KMinDenormalTReal=5E-324; |
|
59 |
|
60 enum TOrder |
|
61 { |
|
62 ELessThan, |
|
63 EEqual, |
|
64 EGreaterThan |
|
65 }; |
|
66 |
|
67 LOCAL_D RTest test(_L("T_R64")); |
|
68 |
|
69 #if defined (__WINS__) || defined (__X86__) |
|
70 |
|
71 LOCAL_C void testConstants() |
|
72 // |
|
73 // Checks that constants are defined as expected in WINS, in case low and high words are swapped |
|
74 // |
|
75 { |
|
76 |
|
77 test(TRealX(TReal32(KMinTReal32in64))==TRealX(KMinTReal32)); |
|
78 test(TRealX(TReal32(KMaxTReal32in64))==TRealX(KMaxTReal32)); |
|
79 } |
|
80 |
|
81 #endif |
|
82 |
|
83 LOCAL_C void initSpecialValues() |
|
84 // |
|
85 // Initialise special values, etc |
|
86 // |
|
87 { |
|
88 |
|
89 SReal64* p64=(SReal64*)&endsInFour; |
|
90 p64->sign=0; |
|
91 p64->exp=1020; |
|
92 p64->msm=0; |
|
93 p64->lsm=0x4; |
|
94 |
|
95 p64=(SReal64*)&arg1; |
|
96 p64->sign=0; |
|
97 p64->exp=1075; |
|
98 p64->msm=0x20000; |
|
99 p64->lsm=0; |
|
100 |
|
101 p64=(SReal64*)&arg2; |
|
102 p64->sign=0; |
|
103 p64->exp=1075; |
|
104 p64->msm=0; |
|
105 p64->lsm=0x2a; |
|
106 |
|
107 p64=(SReal64*)&arg3; |
|
108 p64->sign=0; |
|
109 p64->exp=970; |
|
110 p64->msm=0xc71c7; |
|
111 p64->lsm=0x1c71c71c; |
|
112 } |
|
113 |
|
114 LOCAL_C void testConvert() |
|
115 // |
|
116 // Test conversion from TReal to TReal64 |
|
117 // N.B. Conversions between TRealX and TReal64 are tested by t_r96.cpp |
|
118 // |
|
119 { |
|
120 |
|
121 const TReal input[]= |
|
122 { |
|
123 KMaxTReal,KMinTReal,-KMaxTReal,-KMinTReal, |
|
124 1.7976931348622E+308,-1.7976931348622E+308,2.2250738585073E-308,-2.2250738585073E-308, |
|
125 KMaxTReal32inTReal,KMinTReal32inTReal,-KMaxTReal32inTReal,-KMinTReal32inTReal, |
|
126 0.0,64.5,-64.5,1.54E+180,-1.54E+180,4.72E-225,-4.72E-225, |
|
127 KNegZeroTReal,KPosInfTReal,KNegInfTReal,KMinDenormalTReal, |
|
128 1.2345E-318,-2.4682E-321,1.0E-323,-2.0E-308 |
|
129 }; |
|
130 |
|
131 const TReal64 expect[]= |
|
132 { |
|
133 KMaxTReal64,KMinTReal64,-KMaxTReal64,-KMinTReal64, |
|
134 1.7976931348622E+308,-1.7976931348622E+308,2.2250738585073E-308,-2.2250738585073E-308, |
|
135 KMaxTReal32in64,KMinTReal32in64,-KMaxTReal32in64,-KMinTReal32in64, |
|
136 0.0,64.5,-64.5,1.54E+180,-1.54E+180,4.72E-225,-4.72E-225, |
|
137 KNegZeroTReal64,KPosInfTReal64,KNegInfTReal64,KMinDenormalTReal64, |
|
138 1.2345E-318,-2.4682E-321,1.0E-323,-2.0E-308 |
|
139 }; |
|
140 |
|
141 TInt size = sizeof(input)/sizeof(TReal); |
|
142 TRealX f; |
|
143 |
|
144 for (TInt ii=0; ii<size; ii++) |
|
145 { |
|
146 f=TRealX(TReal64(TRealX(input[ii]))); |
|
147 test(f==TRealX(expect[ii])); |
|
148 } |
|
149 |
|
150 // NaN |
|
151 TReal a=KNaNTReal; |
|
152 // TReal64 b=KNaNTReal64; |
|
153 f=TRealX(TReal64(TRealX(a))); |
|
154 // test(f!=TRealX(b)); |
|
155 test(f.IsNaN()); |
|
156 } |
|
157 |
|
158 LOCAL_C void testAdd() |
|
159 // |
|
160 // Addition tests |
|
161 // |
|
162 { |
|
163 TReal64 f,g,h,y; |
|
164 TRealX ff,gg,hh; |
|
165 |
|
166 for (TInt ii=0; ii<sizeAdd-1; ii++) |
|
167 { |
|
168 f=addInput[ii]; |
|
169 g=addInput[ii+1]; |
|
170 ff=TRealX(f); |
|
171 gg=TRealX(g); |
|
172 // Test commute |
|
173 test(f+g == g+f); |
|
174 // Test PC real addition using fp-hardware same as TRealX addition |
|
175 h=f+g; |
|
176 hh=ff+gg; |
|
177 y=(TReal64)hh; // need to do this since TRealX has too much precision |
|
178 test(y==h); |
|
179 h=g+f; |
|
180 hh=gg+ff; |
|
181 y=(TReal64)hh; // need to do this since TRealX has too much precision |
|
182 test(y==h); |
|
183 // Test hex-encoded constants for TReal64s generated on PC using fp-hardware same as |
|
184 // TRealX addition |
|
185 test(*(TReal64*)&addArray[ii]==f+g); |
|
186 test(*(TReal64*)&addArray[ii]==g+f); |
|
187 // similarly to tests above ... |
|
188 h=g; |
|
189 hh=gg; |
|
190 h+=f; |
|
191 hh+=ff; |
|
192 test(h==(TReal64)hh); |
|
193 test(*(TReal64*)&addArray[ii]==h); |
|
194 // |
|
195 h=f; |
|
196 hh=ff; |
|
197 h+=g; |
|
198 hh+=gg; |
|
199 test(h==(TReal64)hh); |
|
200 test(*(TReal64*)&addArray[ii]==h); |
|
201 } |
|
202 } |
|
203 |
|
204 LOCAL_C void testSub() |
|
205 // |
|
206 // Subtraction tests - see notes in addition test above |
|
207 // |
|
208 { |
|
209 TReal64 f,g,h; |
|
210 TRealX ff,gg,hh; |
|
211 |
|
212 for (TInt ii=0; ii<sizeSub-1; ii++) |
|
213 { |
|
214 f=subInput[ii]; |
|
215 g=subInput[ii+1]; |
|
216 ff=TRealX(f); |
|
217 gg=TRealX(g); |
|
218 // |
|
219 test(f-g == -(g-f)); |
|
220 // |
|
221 test(TRealX(f-g)==ff-gg); |
|
222 test(TRealX(g-f)==gg-ff); |
|
223 test(*(TReal64*)&subArray[ii]==f-g); |
|
224 test(*(TReal64*)&subArray[ii]==-(g-f)); |
|
225 // |
|
226 h=g; |
|
227 hh=gg; |
|
228 test(TRealX(h-=f)==(hh-=ff)); |
|
229 test(TRealX(h)==hh); |
|
230 test(*(TReal64*)&subArray[ii]==-h); |
|
231 // |
|
232 h=f; |
|
233 hh=ff; |
|
234 test(TRealX(h-=g)==(hh-=gg)); |
|
235 test(TRealX(h)==hh); |
|
236 test(*(TReal64*)&subArray[ii]==h); |
|
237 } |
|
238 } |
|
239 |
|
240 LOCAL_C void testMult() |
|
241 // |
|
242 // Multiplication test |
|
243 // |
|
244 { |
|
245 TReal64 f,g,h; |
|
246 TRealX ff,gg,hh; |
|
247 |
|
248 for (TInt ii=0; ii<sizeMult-1; ii++) |
|
249 { |
|
250 f=multInput[ii]; |
|
251 g=multInput[ii+1]; |
|
252 ff=TRealX(f); |
|
253 gg=TRealX(g); |
|
254 // |
|
255 test(f*g == g*f); |
|
256 // |
|
257 test(TRealX(f*g)==ff*gg); |
|
258 test(TRealX(g*f)==gg*ff); |
|
259 test(*(TReal64*)&multArray[ii]==f*g); |
|
260 test(*(TReal64*)&multArray[ii]==g*f); |
|
261 // |
|
262 h=f; |
|
263 hh=ff; |
|
264 test(TRealX(h*=g)==(hh*=gg)); |
|
265 test(TRealX(h)==hh); |
|
266 test(*(TReal64*)&multArray[ii]==h); |
|
267 // |
|
268 h=g; |
|
269 hh=gg; |
|
270 test(TRealX(h*=f)==(hh*=ff)); |
|
271 test(TRealX(h)==hh); |
|
272 test(*(TReal64*)&multArray[ii]==h); |
|
273 } |
|
274 } |
|
275 |
|
276 LOCAL_C void testDiv() |
|
277 // |
|
278 // Division tests |
|
279 // |
|
280 { |
|
281 TReal64 f,g,h; |
|
282 TRealX ff,gg,hh; |
|
283 TInt count=0; |
|
284 |
|
285 // Panic (under ARM) - Divide by Zero - run in DEBUG build as a check only |
|
286 //f=1.0; |
|
287 //g=0.0; |
|
288 //f/=g; |
|
289 |
|
290 for (TInt ii=0; ii<sizeDiv-1; ii++) |
|
291 { |
|
292 f=divInput[ii]; |
|
293 g=divInput[ii+1]; |
|
294 ff=TRealX(f); |
|
295 gg=TRealX(g); |
|
296 if (g!=0.0) |
|
297 { |
|
298 test(TRealX(f/g)==ff/gg); |
|
299 test(*(TReal64*)&divArray[count]==f/g); |
|
300 // |
|
301 h=f; |
|
302 hh=ff; |
|
303 test(TRealX(h/=g)==(hh/=gg)); |
|
304 test(TRealX(h)==hh); |
|
305 test(*(TReal64*)&divArray[count]==h); |
|
306 ++count; |
|
307 } |
|
308 if (f!=0.0) |
|
309 { |
|
310 test(TRealX(g/f)==gg/ff); |
|
311 // |
|
312 h=g; |
|
313 hh=gg; |
|
314 test(TRealX(h/=f)==(hh/=ff)); |
|
315 test(TRealX(h)==hh); |
|
316 } |
|
317 } |
|
318 |
|
319 gg=TRealX(arg2)/TRealX(arg3); |
|
320 |
|
321 //Additional test |
|
322 f=3.999999999999999; |
|
323 g=KMinTReal64; |
|
324 ff=TRealX(f); |
|
325 gg=TRealX(g); |
|
326 test(TRealX(f/g)==ff/gg); |
|
327 h=f; |
|
328 test(TRealX(h/=g)==ff/gg); |
|
329 test(TRealX(h)==ff/gg); |
|
330 } |
|
331 |
|
332 #if defined (__WINS__) || defined (__X86__) |
|
333 |
|
334 LOCAL_C void testArithmeticExceptionRaising() |
|
335 // |
|
336 // Test that UP_GCC.CPP raise exceptions correctly by calling functions from EMGCC64.CPP which |
|
337 // are copies of those in UP_GCC.CPP. To be used in debugger only. |
|
338 // Added by AnnW, December 1996 |
|
339 // |
|
340 { |
|
341 TReal64 f,g,h; |
|
342 |
|
343 // Addition - possible errors are argument, overflow, or none |
|
344 // NB cannot achieve underflow now denormals in use |
|
345 |
|
346 f=KNaNTReal64; |
|
347 h=__adddf3(f,f); // argument |
|
348 |
|
349 f=KMaxTReal64; |
|
350 h=__adddf3(f,f); // overflow |
|
351 |
|
352 f=1.0; |
|
353 g=2.0; |
|
354 h=__adddf3(f,g); // none |
|
355 test(h==3.0); |
|
356 |
|
357 // Subtraction - possible errors are argumnet, overflow or none |
|
358 // NB cannot achieve underflow now denormals in use |
|
359 |
|
360 f=KNaNTReal64; |
|
361 h=__subdf3(f,f); // argument |
|
362 |
|
363 f=KMaxTReal64; |
|
364 g=-KMaxTReal64; |
|
365 h=__subdf3(f,g); // overflow |
|
366 |
|
367 f=1.0; |
|
368 g=2.0; |
|
369 h=__subdf3(f,g); // none |
|
370 test(h==-1.0); |
|
371 |
|
372 // Multiplication - possible errors are argument, overflow, underflow or none |
|
373 |
|
374 f=KNaNTReal64; |
|
375 h=__muldf3(f,f); // argument |
|
376 |
|
377 f=KMaxTReal64; |
|
378 g=2.0; |
|
379 h=__muldf3(f,g); // overflow |
|
380 |
|
381 f=KMinDenormalTReal64; |
|
382 g=0.1; |
|
383 h=__muldf3(f,g); // underflow |
|
384 |
|
385 f=1.0; |
|
386 g=2.0; |
|
387 h=__muldf3(f,g); // none |
|
388 test(h==2.0); |
|
389 |
|
390 // Division - possible errors are overflow, underflow, divide by zero, argument or none |
|
391 |
|
392 f=KMaxTReal64; |
|
393 g=0.5; |
|
394 h=__divdf3(f,g); // overflow |
|
395 |
|
396 f=KMinDenormalTReal64; |
|
397 g=10.0; |
|
398 h=__divdf3(f,g); // underflow |
|
399 |
|
400 f=4.0; |
|
401 g=0.0; |
|
402 h=__divdf3(f,g); // divide by zero |
|
403 |
|
404 f=0.0; |
|
405 g=0.0; |
|
406 h=__divdf3(f,g); // argument |
|
407 |
|
408 f=1.0; |
|
409 g=2.0; |
|
410 h=__divdf3(f,g); // none |
|
411 test(h==0.5); |
|
412 } |
|
413 |
|
414 #endif |
|
415 |
|
416 LOCAL_C void testUnary() |
|
417 // |
|
418 // Unary operator tests |
|
419 // |
|
420 { |
|
421 TReal64 f; |
|
422 TRealX g; |
|
423 |
|
424 for (TInt ii=0; ii<sizeUnary-1; ii++) |
|
425 { |
|
426 f=unaryInput[ii]; |
|
427 g=TRealX(f); |
|
428 test(TRealX(-f)==-g); |
|
429 test(TRealX(-f)==TRealX(0-f)); |
|
430 test(TRealX(+f)==g); |
|
431 test(TRealX(+f)==TRealX(0+f)); |
|
432 test(*(TReal64*)&unaryArray[ii]==-f); |
|
433 } |
|
434 } |
|
435 |
|
436 LOCAL_C void testEqualities(const TReal& aA, TOrder aOrder, const TReal& aB) |
|
437 // |
|
438 // Test equality/inequality functions on aA and aB |
|
439 // aOrder specifies the operand's relative sizes |
|
440 // |
|
441 { |
|
442 // Tautologies |
|
443 test((aA>aA) ==FALSE); |
|
444 test((aA<aA) ==FALSE); |
|
445 test((aA>=aA)==TRUE); |
|
446 test((aA<=aA)==TRUE); |
|
447 test((aA==aA)==TRUE); |
|
448 test((aA!=aA)==FALSE); |
|
449 |
|
450 if (aOrder!=EEqual) |
|
451 { |
|
452 test((aA==aB)==FALSE); |
|
453 test((aA!=aB)==TRUE); |
|
454 } |
|
455 |
|
456 if (aOrder==ELessThan) |
|
457 { |
|
458 test((aA<aB) ==TRUE); |
|
459 test((aA<=aB)==TRUE); |
|
460 test((aA>aB) ==FALSE); |
|
461 test((aA>=aB)==FALSE); |
|
462 } |
|
463 |
|
464 if (aOrder==EEqual) |
|
465 { |
|
466 test((aA==aB)==TRUE); |
|
467 test((aA!=aB)==FALSE); |
|
468 test((aA>=aB)==TRUE); |
|
469 test((aA<=aB)==TRUE); |
|
470 test((aA>aB)==FALSE); |
|
471 test((aA<aB)==FALSE); |
|
472 } |
|
473 |
|
474 if (aOrder==EGreaterThan) |
|
475 { |
|
476 test((aA>aB) ==TRUE); |
|
477 test((aA>=aB)==TRUE); |
|
478 test((aA<aB) ==FALSE); |
|
479 test((aA<=aB)==FALSE); |
|
480 } |
|
481 } |
|
482 |
|
483 LOCAL_C void testEqualities() |
|
484 // |
|
485 // Test >, <, >=, <=, ==, != |
|
486 // |
|
487 { |
|
488 TInt i, size; |
|
489 TReal64 lessThanMax = KMaxTReal64-TReal64(1.0E+294); |
|
490 TReal64 greaterThanMin = TReal64(2.225075E-308); |
|
491 TReal64 zero(0.0); |
|
492 |
|
493 TReal64 positive[] = |
|
494 {KMinTReal64,5.3824705392348592E-138,1.0,2387501,5.3824705392348592E+138,KMaxTReal64}; |
|
495 |
|
496 TReal64 large[] = |
|
497 {2.0,KMaxTReal64,-lessThanMax,greaterThanMin,-KMinTReal64,10.40584821945060,-10.40584821945058, |
|
498 1.244334567201E+105,1.244334567201E+105,-1.3420344230402E-106,132435.97865,5.0E-16,9.6,-8.0}; |
|
499 |
|
500 TReal64 small[] = |
|
501 {1.0,lessThanMax,-KMaxTReal64,KMinTReal64,-greaterThanMin,10.40584821945058,-10.40584821945060, |
|
502 50E-100,1.244334567201E+104,-5.03824705392348592E+58,-132435.97865,-5.1E-16,8.0,-9.6}; |
|
503 |
|
504 TReal64 equal[] = // Same as large[] |
|
505 {2.0,KMaxTReal64,-lessThanMax,greaterThanMin,-KMinTReal64,10.40584821945060,-10.40584821945058, |
|
506 1.244334567201E+105,1.244334567201E+105,-1.3420344230402E-106,132435.97865,5.0E-16,9.6,-8.0}; |
|
507 |
|
508 // Tests with zero |
|
509 |
|
510 size = sizeof(positive)/sizeof(TReal64); |
|
511 |
|
512 test.Start(_L("Zero")); |
|
513 testEqualities(zero, EEqual, zero); |
|
514 for (i=0; i<size; i++) |
|
515 { |
|
516 testEqualities(positive[i], EGreaterThan, zero); |
|
517 testEqualities(-positive[i], ELessThan, zero); |
|
518 testEqualities(zero, ELessThan, positive[i]); |
|
519 testEqualities(zero, EGreaterThan, -positive[i]); |
|
520 } |
|
521 |
|
522 // Test boundary and other numbers |
|
523 |
|
524 size = sizeof(large)/sizeof(TReal64); |
|
525 |
|
526 test.Next(_L("Nonzero")); |
|
527 for (i=0; i<size; i++) |
|
528 { |
|
529 testEqualities(large[i], EGreaterThan, small[i]); |
|
530 testEqualities(small[i], ELessThan, large[i]); |
|
531 testEqualities(large[i], EEqual, equal[i]); |
|
532 } |
|
533 |
|
534 test.End(); |
|
535 } |
|
536 |
|
537 LOCAL_C void testIncDec() |
|
538 // |
|
539 // Test Pre/Post-increment/decrement |
|
540 // |
|
541 { |
|
542 TInt ii; |
|
543 TReal64 f; |
|
544 TRealX g; |
|
545 |
|
546 test.Start(_L("Pre-increment")); |
|
547 |
|
548 for (ii=0; ii<sizeIncDec; ii++) |
|
549 { |
|
550 f=incDecInput[ii]; |
|
551 g=TRealX(f); |
|
552 test(TRealX(f)==g); |
|
553 test(TRealX(++f)==(++g)); |
|
554 test(*(TReal64*)&preIncArray1[ii]==f); |
|
555 test(TRealX(f)==g); |
|
556 test(TRealX(++f)==(++g)); |
|
557 test(*(TReal64*)&preIncArray2[ii]==f); |
|
558 test(TRealX(f)==g); |
|
559 } |
|
560 |
|
561 test.Next(_L("Post-increment")); |
|
562 |
|
563 for (ii=0; ii<sizeIncDec; ii++) |
|
564 { |
|
565 f=incDecInput[ii]; |
|
566 g=TRealX(f); |
|
567 test(TRealX(f)==g); |
|
568 test(TRealX(f++)==(g++)); |
|
569 test(*(TReal64*)&postIncArray1[ii]==f); |
|
570 test(TRealX(f)==g); |
|
571 test(TRealX(f++)==(g++)); |
|
572 test(*(TReal64*)&postIncArray2[ii]==f); |
|
573 test(TRealX(f)==g); |
|
574 } |
|
575 |
|
576 test.Next(_L("Pre-decrement")); |
|
577 |
|
578 for (ii=0; ii<sizeIncDec; ii++) |
|
579 { |
|
580 f=incDecInput[ii]; |
|
581 g=TRealX(f); |
|
582 test(TRealX(f)==g); |
|
583 test(TRealX(--f)==(--g)); |
|
584 test(*(TReal64*)&preDecArray1[ii]==f); |
|
585 test(TRealX(f)==g); |
|
586 test(TRealX(--f)==(--g)); |
|
587 test(*(TReal64*)&preDecArray2[ii]==f); |
|
588 test(TRealX(f)==g); |
|
589 } |
|
590 |
|
591 test.Next(_L("Post-decrement")); |
|
592 |
|
593 for (ii=0; ii<sizeIncDec; ii++) |
|
594 { |
|
595 f=incDecInput[ii]; |
|
596 g=TRealX(f); |
|
597 test(TRealX(f)==g); |
|
598 test(TRealX(f--)==(g--)); |
|
599 test(*(TReal64*)&postDecArray1[ii]==f); |
|
600 test(TRealX(f)==g); |
|
601 test(TRealX(f--)==(g--)); |
|
602 test(*(TReal64*)&postDecArray2[ii]==f); |
|
603 test(TRealX(f)==g); |
|
604 } |
|
605 test.End(); |
|
606 } |
|
607 |
|
608 LOCAL_C void _matherr(TExcType aType) |
|
609 // |
|
610 // Dummy function to handle exceptions |
|
611 // |
|
612 { |
|
613 |
|
614 test.Printf(_L("_matherr: Exception type %u handled\n"),TUint(aType)); |
|
615 } |
|
616 |
|
617 |
|
618 GLDEF_C TInt E32Main() |
|
619 // |
|
620 // Test TReal64 |
|
621 // |
|
622 { |
|
623 |
|
624 test.Title(); |
|
625 |
|
626 #if defined (__X86__) |
|
627 TInt16 cw=0; |
|
628 _asm fstcw cw; |
|
629 test.Printf(_L("control word = 0x%x\n"),cw); |
|
630 cw=0x27f; // WINS value |
|
631 _asm fldcw cw; |
|
632 #endif |
|
633 |
|
634 // Set exceptions to be handled |
|
635 RThread myThread; |
|
636 myThread.SetExceptionHandler(_matherr,KExceptionFpe); |
|
637 |
|
638 initSpecialValues(); |
|
639 |
|
640 #if defined (__WINS__) || defined (__X86__) |
|
641 test.Start(_L("Checking double words not swapped...")); |
|
642 testConstants(); |
|
643 test.Next(_L("Conversion from TReal to TReal64")); |
|
644 testConvert(); |
|
645 #else |
|
646 test.Start(_L("Conversion from TReal to TReal64")); |
|
647 testConvert(); |
|
648 #endif |
|
649 test.Next(_L("Conversion from TReal to TReal64")); |
|
650 testConvert(); |
|
651 test.Next(_L("Addition")); |
|
652 testAdd(); |
|
653 test.Next(_L("Subtraction")); |
|
654 testSub(); |
|
655 test.Next(_L("Multiplication")); |
|
656 testMult(); |
|
657 test.Next(_L("Division")); |
|
658 testDiv(); |
|
659 #if defined (__WINS__) || defined (__X86__) |
|
660 test.Next(_L("Arithmetic which emulates UP_GCC and raises an exception")); |
|
661 testArithmeticExceptionRaising(); |
|
662 #endif |
|
663 test.Next(_L("Unary Operations")); |
|
664 testUnary(); |
|
665 test.Next(_L("Equalities and Inequalities")); |
|
666 testEqualities(); |
|
667 test.Next(_L("Increment and Decrement")); |
|
668 testIncDec(); |
|
669 |
|
670 test.End(); |
|
671 return(KErrNone); |
|
672 } |
|
673 |
|
674 |