sl@0
|
1 |
// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// e32test\math\t_realx.cpp
|
sl@0
|
15 |
// T_REALX.CPP - Test routines for TRealX
|
sl@0
|
16 |
// Overview:
|
sl@0
|
17 |
// Test the functionality of a class that encapsulates 64 bit extended precision
|
sl@0
|
18 |
// real values.
|
sl@0
|
19 |
// API Information:
|
sl@0
|
20 |
// TRealX
|
sl@0
|
21 |
// Details:
|
sl@0
|
22 |
// - Test the constructor and assignment operator with signed, unsigned, 64 bit
|
sl@0
|
23 |
// integer, float and double values.
|
sl@0
|
24 |
// - Check the conversion of TRealX value to signed, unsigned, 64 bit integer,
|
sl@0
|
25 |
// float and double values is as expected.
|
sl@0
|
26 |
// - Set TRealX variable with some special values and check it is as expected.
|
sl@0
|
27 |
// - Test addition, multiplication, division of TRealX values is as expected.
|
sl@0
|
28 |
// - Test Unary operators, comparison of two TRealX values are as expected.
|
sl@0
|
29 |
// Platforms/Drives/Compatibility:
|
sl@0
|
30 |
// All
|
sl@0
|
31 |
// Assumptions/Requirement/Pre-requisites:
|
sl@0
|
32 |
// Failures and causes:
|
sl@0
|
33 |
// Base Port information:
|
sl@0
|
34 |
//
|
sl@0
|
35 |
//
|
sl@0
|
36 |
|
sl@0
|
37 |
#include <e32std.h>
|
sl@0
|
38 |
#include <e32std_private.h>
|
sl@0
|
39 |
#include <e32test.h>
|
sl@0
|
40 |
#include <e32math.h>
|
sl@0
|
41 |
#include "t_realxd.h"
|
sl@0
|
42 |
|
sl@0
|
43 |
LOCAL_D RTest test(_L("T_TREALX"));
|
sl@0
|
44 |
|
sl@0
|
45 |
// Conversion functions TInt64 <-> TReal64
|
sl@0
|
46 |
LOCAL_C void TReal64ToTInt64(TInt64 *aDest, const TReal64 *aSrc)
|
sl@0
|
47 |
{
|
sl@0
|
48 |
TInt *pD=(TInt*)aDest;
|
sl@0
|
49 |
const TInt *pS=(TInt*)aSrc;
|
sl@0
|
50 |
#ifdef __DOUBLE_WORDS_SWAPPED__
|
sl@0
|
51 |
pD[1]=pS[0]; // word containing sign,exp
|
sl@0
|
52 |
pD[0]=pS[1];
|
sl@0
|
53 |
#else
|
sl@0
|
54 |
pD[1]=pS[1]; // word containing sign,exp
|
sl@0
|
55 |
pD[0]=pS[0];
|
sl@0
|
56 |
#endif
|
sl@0
|
57 |
}
|
sl@0
|
58 |
|
sl@0
|
59 |
LOCAL_C void TInt64ToTReal64(TReal64 *aDest, const TInt64 *aSrc)
|
sl@0
|
60 |
{
|
sl@0
|
61 |
TInt *pD=(TInt*)aDest;
|
sl@0
|
62 |
const TInt *pS=(TInt*)aSrc;
|
sl@0
|
63 |
#ifdef __DOUBLE_WORDS_SWAPPED__
|
sl@0
|
64 |
pD[0]=pS[1]; // word containing sign,exp
|
sl@0
|
65 |
pD[1]=pS[0];
|
sl@0
|
66 |
#else
|
sl@0
|
67 |
pD[1]=pS[1]; // word containing sign,exp
|
sl@0
|
68 |
pD[0]=pS[0];
|
sl@0
|
69 |
#endif
|
sl@0
|
70 |
}
|
sl@0
|
71 |
|
sl@0
|
72 |
// Test functions
|
sl@0
|
73 |
SRealX::SRealX(TUint a, TUint b, TUint c)
|
sl@0
|
74 |
{
|
sl@0
|
75 |
iExpFlagSign=a;
|
sl@0
|
76 |
iMantHigh=b;
|
sl@0
|
77 |
iMantLow=c;
|
sl@0
|
78 |
}
|
sl@0
|
79 |
|
sl@0
|
80 |
SRealX::SRealX(const TRealX& aRealX)
|
sl@0
|
81 |
{
|
sl@0
|
82 |
const TUint *pR = (const TUint *)&aRealX;
|
sl@0
|
83 |
iExpFlagSign=pR[2];
|
sl@0
|
84 |
iMantHigh=pR[1];
|
sl@0
|
85 |
iMantLow=pR[0];
|
sl@0
|
86 |
}
|
sl@0
|
87 |
|
sl@0
|
88 |
SRealX& SRealX::operator=(const TRealX& aRealX)
|
sl@0
|
89 |
{
|
sl@0
|
90 |
const TUint *pR = (const TUint *)&aRealX;
|
sl@0
|
91 |
iExpFlagSign=pR[2];
|
sl@0
|
92 |
iMantHigh=pR[1];
|
sl@0
|
93 |
iMantLow=pR[0];
|
sl@0
|
94 |
return *this;
|
sl@0
|
95 |
}
|
sl@0
|
96 |
|
sl@0
|
97 |
SRealX::operator TRealX() const
|
sl@0
|
98 |
{
|
sl@0
|
99 |
TRealX r;
|
sl@0
|
100 |
TUint *pR=(TUint *)&r;
|
sl@0
|
101 |
pR[2]=iExpFlagSign;
|
sl@0
|
102 |
pR[1]=iMantHigh;
|
sl@0
|
103 |
pR[0]=iMantLow;
|
sl@0
|
104 |
return r;
|
sl@0
|
105 |
}
|
sl@0
|
106 |
|
sl@0
|
107 |
TBool SRealX::operator==(const SRealX& aSRealX) const
|
sl@0
|
108 |
{
|
sl@0
|
109 |
TUint e1=iExpFlagSign >> 16;
|
sl@0
|
110 |
TUint e2=aSRealX.iExpFlagSign >> 16;
|
sl@0
|
111 |
TUint s1=iExpFlagSign & 0x00000001;
|
sl@0
|
112 |
TUint s2=aSRealX.iExpFlagSign & 0x00000001;
|
sl@0
|
113 |
TUint f1=iExpFlagSign & 0x00000300;
|
sl@0
|
114 |
TUint f2=aSRealX.iExpFlagSign & 0x00000300;
|
sl@0
|
115 |
return( e1==e2 && s1==s2 && (e1==0 || (f1==f2 && iMantHigh==aSRealX.iMantHigh && iMantLow==aSRealX.iMantLow)) );
|
sl@0
|
116 |
}
|
sl@0
|
117 |
|
sl@0
|
118 |
SConvertFrom32BitTest::SConvertFrom32BitTest(TInt op, const SRealX& res, TInt r)
|
sl@0
|
119 |
{
|
sl@0
|
120 |
iOperand=op;
|
sl@0
|
121 |
iResult=res;
|
sl@0
|
122 |
iReturnCode=r;
|
sl@0
|
123 |
}
|
sl@0
|
124 |
|
sl@0
|
125 |
void SConvertFrom32BitTest::Test(TConversionFrom32Bits aConversion) const
|
sl@0
|
126 |
{
|
sl@0
|
127 |
TInt r=iReturnCode;
|
sl@0
|
128 |
SRealX sr;
|
sl@0
|
129 |
switch(aConversion)
|
sl@0
|
130 |
{
|
sl@0
|
131 |
case EConstructInt:
|
sl@0
|
132 |
{
|
sl@0
|
133 |
TRealX x(iOperand);
|
sl@0
|
134 |
sr=(SRealX)x;
|
sl@0
|
135 |
break;
|
sl@0
|
136 |
}
|
sl@0
|
137 |
case EAssignInt:
|
sl@0
|
138 |
{
|
sl@0
|
139 |
TRealX x;
|
sl@0
|
140 |
x=iOperand;
|
sl@0
|
141 |
sr=(SRealX)x;
|
sl@0
|
142 |
break;
|
sl@0
|
143 |
}
|
sl@0
|
144 |
case ESetInt:
|
sl@0
|
145 |
{
|
sl@0
|
146 |
TRealX x;
|
sl@0
|
147 |
r=x.Set(iOperand);
|
sl@0
|
148 |
sr=(SRealX)x;
|
sl@0
|
149 |
break;
|
sl@0
|
150 |
}
|
sl@0
|
151 |
case EConstructUint:
|
sl@0
|
152 |
{
|
sl@0
|
153 |
TUint uint=(TUint)iOperand;
|
sl@0
|
154 |
TRealX x(uint);
|
sl@0
|
155 |
sr=(SRealX)x;
|
sl@0
|
156 |
break;
|
sl@0
|
157 |
}
|
sl@0
|
158 |
case EAssignUint:
|
sl@0
|
159 |
{
|
sl@0
|
160 |
TUint uint=(TUint)iOperand;
|
sl@0
|
161 |
TRealX x;
|
sl@0
|
162 |
x=uint;
|
sl@0
|
163 |
sr=(SRealX)x;
|
sl@0
|
164 |
break;
|
sl@0
|
165 |
}
|
sl@0
|
166 |
case ESetUint:
|
sl@0
|
167 |
{
|
sl@0
|
168 |
TUint uint=(TUint)iOperand;
|
sl@0
|
169 |
TRealX x;
|
sl@0
|
170 |
r=x.Set(uint);
|
sl@0
|
171 |
sr=(SRealX)x;
|
sl@0
|
172 |
break;
|
sl@0
|
173 |
}
|
sl@0
|
174 |
case EConstructFloat:
|
sl@0
|
175 |
{
|
sl@0
|
176 |
TReal32 f;
|
sl@0
|
177 |
TInt *pF=(TInt*)&f;
|
sl@0
|
178 |
*pF=iOperand;
|
sl@0
|
179 |
TRealX x(f);
|
sl@0
|
180 |
sr=(SRealX)x;
|
sl@0
|
181 |
break;
|
sl@0
|
182 |
}
|
sl@0
|
183 |
case EAssignFloat:
|
sl@0
|
184 |
{
|
sl@0
|
185 |
TReal32 f;
|
sl@0
|
186 |
TInt *pF=(TInt*)&f;
|
sl@0
|
187 |
*pF=iOperand;
|
sl@0
|
188 |
TRealX x;
|
sl@0
|
189 |
x=f;
|
sl@0
|
190 |
sr=(SRealX)x;
|
sl@0
|
191 |
break;
|
sl@0
|
192 |
}
|
sl@0
|
193 |
case ESetFloat:
|
sl@0
|
194 |
{
|
sl@0
|
195 |
TReal32 f;
|
sl@0
|
196 |
TInt *pF=(TInt*)&f;
|
sl@0
|
197 |
*pF=iOperand;
|
sl@0
|
198 |
TRealX x;
|
sl@0
|
199 |
r=x.Set(f);
|
sl@0
|
200 |
sr=(SRealX)x;
|
sl@0
|
201 |
break;
|
sl@0
|
202 |
}
|
sl@0
|
203 |
}
|
sl@0
|
204 |
if (sr==iResult && r==iReturnCode)
|
sl@0
|
205 |
return;
|
sl@0
|
206 |
test.Printf(_L("Conversion %d from 32 bit operand test failed\noperand = %08X\n"),
|
sl@0
|
207 |
(TInt)aConversion, iOperand );
|
sl@0
|
208 |
test.Printf(_L("Result %08X %08X %08X\nReturn code %d\n"),
|
sl@0
|
209 |
sr.iExpFlagSign, sr.iMantHigh, sr.iMantLow, r );
|
sl@0
|
210 |
test.Printf(_L("Correct result %08X %08X %08X\nCorrect return code %d\n"),
|
sl@0
|
211 |
iResult.iExpFlagSign, iResult.iMantHigh, iResult.iMantLow, iReturnCode );
|
sl@0
|
212 |
//test.Getch();
|
sl@0
|
213 |
test(0);
|
sl@0
|
214 |
}
|
sl@0
|
215 |
|
sl@0
|
216 |
SConvertFrom64BitTest::SConvertFrom64BitTest(TInt64 op, const SRealX& res, TInt r)
|
sl@0
|
217 |
{
|
sl@0
|
218 |
iOperand=op;
|
sl@0
|
219 |
iResult=res;
|
sl@0
|
220 |
iReturnCode=r;
|
sl@0
|
221 |
}
|
sl@0
|
222 |
|
sl@0
|
223 |
void SConvertFrom64BitTest::Test(TConversionFrom64Bits aConversion) const
|
sl@0
|
224 |
{
|
sl@0
|
225 |
TInt r=iReturnCode;
|
sl@0
|
226 |
SRealX sr;
|
sl@0
|
227 |
switch(aConversion)
|
sl@0
|
228 |
{
|
sl@0
|
229 |
case EConstructInt64:
|
sl@0
|
230 |
{
|
sl@0
|
231 |
TRealX x(iOperand);
|
sl@0
|
232 |
sr=(SRealX)x;
|
sl@0
|
233 |
break;
|
sl@0
|
234 |
}
|
sl@0
|
235 |
case EAssignInt64:
|
sl@0
|
236 |
{
|
sl@0
|
237 |
TRealX x;
|
sl@0
|
238 |
x=iOperand;
|
sl@0
|
239 |
sr=(SRealX)x;
|
sl@0
|
240 |
break;
|
sl@0
|
241 |
}
|
sl@0
|
242 |
case ESetInt64:
|
sl@0
|
243 |
{
|
sl@0
|
244 |
TRealX x;
|
sl@0
|
245 |
r=x.Set(iOperand);
|
sl@0
|
246 |
sr=(SRealX)x;
|
sl@0
|
247 |
break;
|
sl@0
|
248 |
}
|
sl@0
|
249 |
/* case EConstructUint:
|
sl@0
|
250 |
{
|
sl@0
|
251 |
TUint uint=(TUint)iOperand;
|
sl@0
|
252 |
TRealX x(uint);
|
sl@0
|
253 |
sr=(SRealX)x;
|
sl@0
|
254 |
break;
|
sl@0
|
255 |
}
|
sl@0
|
256 |
case EAssignUint:
|
sl@0
|
257 |
{
|
sl@0
|
258 |
TUint uint=(TUint)iOperand;
|
sl@0
|
259 |
TRealX x;
|
sl@0
|
260 |
x=uint;
|
sl@0
|
261 |
sr=(SRealX)x;
|
sl@0
|
262 |
break;
|
sl@0
|
263 |
}
|
sl@0
|
264 |
case ESetUint:
|
sl@0
|
265 |
{
|
sl@0
|
266 |
TUint uint=(TUint)iOperand;
|
sl@0
|
267 |
TRealX x;
|
sl@0
|
268 |
r=x.Set(uint);
|
sl@0
|
269 |
sr=(SRealX)x;
|
sl@0
|
270 |
break;
|
sl@0
|
271 |
}*/
|
sl@0
|
272 |
case EConstructDouble:
|
sl@0
|
273 |
{
|
sl@0
|
274 |
TReal64 d;
|
sl@0
|
275 |
TInt64ToTReal64(&d, &iOperand);
|
sl@0
|
276 |
TRealX x(d);
|
sl@0
|
277 |
sr=(SRealX)x;
|
sl@0
|
278 |
break;
|
sl@0
|
279 |
}
|
sl@0
|
280 |
case EAssignDouble:
|
sl@0
|
281 |
{
|
sl@0
|
282 |
TReal64 d;
|
sl@0
|
283 |
TInt64ToTReal64(&d, &iOperand);
|
sl@0
|
284 |
TRealX x;
|
sl@0
|
285 |
x=d;
|
sl@0
|
286 |
sr=(SRealX)x;
|
sl@0
|
287 |
break;
|
sl@0
|
288 |
}
|
sl@0
|
289 |
case ESetDouble:
|
sl@0
|
290 |
{
|
sl@0
|
291 |
TReal64 d;
|
sl@0
|
292 |
TInt64ToTReal64(&d, &iOperand);
|
sl@0
|
293 |
TRealX x;
|
sl@0
|
294 |
r=x.Set(d);
|
sl@0
|
295 |
sr=(SRealX)x;
|
sl@0
|
296 |
break;
|
sl@0
|
297 |
}
|
sl@0
|
298 |
}
|
sl@0
|
299 |
if (sr==iResult && r==iReturnCode)
|
sl@0
|
300 |
return;
|
sl@0
|
301 |
test.Printf(_L("Conversion %d from 64 bit operand test failed\noperand = %08X %08X\n"),
|
sl@0
|
302 |
(TInt)aConversion, I64HIGH(iOperand), I64LOW(iOperand) );
|
sl@0
|
303 |
test.Printf(_L("Result %08X %08X %08X\nReturn code %d\n"),
|
sl@0
|
304 |
sr.iExpFlagSign, sr.iMantHigh, sr.iMantLow, r );
|
sl@0
|
305 |
test.Printf(_L("Correct result %08X %08X %08X\nCorrect return code %d\n"),
|
sl@0
|
306 |
iResult.iExpFlagSign, iResult.iMantHigh, iResult.iMantLow, iReturnCode );
|
sl@0
|
307 |
//test.Getch();
|
sl@0
|
308 |
test(0);
|
sl@0
|
309 |
}
|
sl@0
|
310 |
|
sl@0
|
311 |
SConvertTo32BitTest::SConvertTo32BitTest(const SRealX& op, TInt res, TInt r)
|
sl@0
|
312 |
{
|
sl@0
|
313 |
iOperand=op;
|
sl@0
|
314 |
iResult=res;
|
sl@0
|
315 |
iReturnCode=r;
|
sl@0
|
316 |
}
|
sl@0
|
317 |
|
sl@0
|
318 |
void SConvertTo32BitTest::Test(TConversionTo32Bits aConversion) const
|
sl@0
|
319 |
{
|
sl@0
|
320 |
TInt r=iReturnCode;
|
sl@0
|
321 |
TRealX op=(TRealX)iOperand;
|
sl@0
|
322 |
TInt result=0;
|
sl@0
|
323 |
switch(aConversion)
|
sl@0
|
324 |
{
|
sl@0
|
325 |
case EOperatorInt:
|
sl@0
|
326 |
result=(TInt)op;
|
sl@0
|
327 |
break;
|
sl@0
|
328 |
case EOperatorUint:
|
sl@0
|
329 |
{
|
sl@0
|
330 |
TUint uint;
|
sl@0
|
331 |
uint=(TUint)op;
|
sl@0
|
332 |
result=(TInt)uint;
|
sl@0
|
333 |
break;
|
sl@0
|
334 |
}
|
sl@0
|
335 |
case EOperatorTReal32:
|
sl@0
|
336 |
{
|
sl@0
|
337 |
TReal32 x;
|
sl@0
|
338 |
x=(TReal32)op;
|
sl@0
|
339 |
result=*((TInt*)&x);
|
sl@0
|
340 |
break;
|
sl@0
|
341 |
}
|
sl@0
|
342 |
case EGetTReal32:
|
sl@0
|
343 |
{
|
sl@0
|
344 |
TReal32 x;
|
sl@0
|
345 |
r=op.GetTReal(x);
|
sl@0
|
346 |
result=*((TInt*)&x);
|
sl@0
|
347 |
break;
|
sl@0
|
348 |
}
|
sl@0
|
349 |
}
|
sl@0
|
350 |
if (result==iResult && r==iReturnCode)
|
sl@0
|
351 |
return;
|
sl@0
|
352 |
test.Printf(_L("Conversion %d to 32 bit operand test failed\noperand = %08X %08X %08X\n"),
|
sl@0
|
353 |
(TInt)aConversion, iOperand.iExpFlagSign, iOperand.iMantHigh, iOperand.iMantLow );
|
sl@0
|
354 |
test.Printf(_L("Result %08X\nReturn code %d\n"),
|
sl@0
|
355 |
result, r );
|
sl@0
|
356 |
test.Printf(_L("Correct result %08X\nCorrect return code %d\n"),
|
sl@0
|
357 |
iResult, iReturnCode );
|
sl@0
|
358 |
//test.Getch();
|
sl@0
|
359 |
test(0);
|
sl@0
|
360 |
}
|
sl@0
|
361 |
|
sl@0
|
362 |
SConvertTo64BitTest::SConvertTo64BitTest(const SRealX& op, TInt64 res, TInt r)
|
sl@0
|
363 |
{
|
sl@0
|
364 |
iOperand=op;
|
sl@0
|
365 |
iResult=res;
|
sl@0
|
366 |
iReturnCode=r;
|
sl@0
|
367 |
}
|
sl@0
|
368 |
|
sl@0
|
369 |
void SConvertTo64BitTest::Test(TConversionTo64Bits aConversion) const
|
sl@0
|
370 |
{
|
sl@0
|
371 |
TInt r=iReturnCode;
|
sl@0
|
372 |
TRealX op=(TRealX)iOperand;
|
sl@0
|
373 |
TInt64 result=0;
|
sl@0
|
374 |
switch(aConversion)
|
sl@0
|
375 |
{
|
sl@0
|
376 |
case EOperatorInt64:
|
sl@0
|
377 |
result=op.operator TInt64(); // odd conversion syntax required for VC5 compilation
|
sl@0
|
378 |
break;
|
sl@0
|
379 |
case EOperatorTReal64:
|
sl@0
|
380 |
{
|
sl@0
|
381 |
TReal64 d;
|
sl@0
|
382 |
d=(TReal64)op;
|
sl@0
|
383 |
TReal64ToTInt64(&result, &d);
|
sl@0
|
384 |
break;
|
sl@0
|
385 |
}
|
sl@0
|
386 |
case EGetTReal64:
|
sl@0
|
387 |
{
|
sl@0
|
388 |
TReal64 d;
|
sl@0
|
389 |
r=op.GetTReal(d);
|
sl@0
|
390 |
TReal64ToTInt64(&result, &d);
|
sl@0
|
391 |
break;
|
sl@0
|
392 |
}
|
sl@0
|
393 |
}
|
sl@0
|
394 |
if (result==iResult && r==iReturnCode)
|
sl@0
|
395 |
return;
|
sl@0
|
396 |
test.Printf(_L("Conversion %d to 64 bit operand test failed\noperand = %08X %08X %08X\n"),
|
sl@0
|
397 |
(TInt)aConversion, iOperand.iExpFlagSign, iOperand.iMantHigh, iOperand.iMantLow );
|
sl@0
|
398 |
test.Printf(_L("Result %08X %08X\nReturn code %d\n"),
|
sl@0
|
399 |
I64HIGH(result), I64LOW(result), r );
|
sl@0
|
400 |
test.Printf(_L("Correct result %08X %08X\nCorrect return code %d\n"),
|
sl@0
|
401 |
I64HIGH(iResult), I64LOW(iResult), iReturnCode );
|
sl@0
|
402 |
//test.Getch();
|
sl@0
|
403 |
test(0);
|
sl@0
|
404 |
}
|
sl@0
|
405 |
|
sl@0
|
406 |
SCompareTest::SCompareTest(const SRealX& o1, const SRealX& o2, TInt r)
|
sl@0
|
407 |
{
|
sl@0
|
408 |
iOperand1=o1;
|
sl@0
|
409 |
iOperand2=o2;
|
sl@0
|
410 |
iReturnCode=r;
|
sl@0
|
411 |
}
|
sl@0
|
412 |
|
sl@0
|
413 |
void SCompareTest::Test() const
|
sl@0
|
414 |
{
|
sl@0
|
415 |
TRealX op1=(TRealX)iOperand1;
|
sl@0
|
416 |
TRealX op2=(TRealX)iOperand2;
|
sl@0
|
417 |
TRealX::TRealXOrder r=op1.Compare(op2);
|
sl@0
|
418 |
TBool lt=op1<op2;
|
sl@0
|
419 |
TBool le=op1<=op2;
|
sl@0
|
420 |
TBool gt=op1>op2;
|
sl@0
|
421 |
TBool ge=op1>=op2;
|
sl@0
|
422 |
TBool eq=op1==op2;
|
sl@0
|
423 |
TBool ne=op1!=op2;
|
sl@0
|
424 |
if ((TInt)r==iReturnCode)
|
sl@0
|
425 |
{
|
sl@0
|
426 |
switch(r)
|
sl@0
|
427 |
{
|
sl@0
|
428 |
case TRealX::ELessThan:
|
sl@0
|
429 |
if (lt && le && !gt && !ge && !eq && ne)
|
sl@0
|
430 |
return;
|
sl@0
|
431 |
break;
|
sl@0
|
432 |
|
sl@0
|
433 |
case TRealX::EEqual:
|
sl@0
|
434 |
if (!lt && le && !gt && ge && eq && !ne)
|
sl@0
|
435 |
return;
|
sl@0
|
436 |
break;
|
sl@0
|
437 |
case TRealX::EGreaterThan:
|
sl@0
|
438 |
if (!lt && !le && gt && ge && !eq && ne)
|
sl@0
|
439 |
return;
|
sl@0
|
440 |
break;
|
sl@0
|
441 |
|
sl@0
|
442 |
case TRealX::EUnordered:
|
sl@0
|
443 |
if (!lt && !le && !gt && !ge && !eq && ne)
|
sl@0
|
444 |
return;
|
sl@0
|
445 |
break;
|
sl@0
|
446 |
}
|
sl@0
|
447 |
}
|
sl@0
|
448 |
test.Printf(_L("Compare test failed\nop1 = %08X %08X %08X\nop2 = %08X %08X %08X\n"),
|
sl@0
|
449 |
iOperand1.iExpFlagSign, iOperand1.iMantHigh, iOperand1.iMantLow,
|
sl@0
|
450 |
iOperand2.iExpFlagSign, iOperand2.iMantHigh, iOperand2.iMantLow );
|
sl@0
|
451 |
test.Printf(_L("Return code %d\nlt=%d, le=%d, gt=%d, ge=%d, eq=%d, ne=%d\n"),
|
sl@0
|
452 |
r, lt, le, gt, ge, eq, ne );
|
sl@0
|
453 |
//test.Getch();
|
sl@0
|
454 |
test(0);
|
sl@0
|
455 |
}
|
sl@0
|
456 |
|
sl@0
|
457 |
SOneOpTest::SOneOpTest(const SRealX& op, const SRealX& res, TInt r)
|
sl@0
|
458 |
{
|
sl@0
|
459 |
iOperand=op;
|
sl@0
|
460 |
iResult=res;
|
sl@0
|
461 |
iReturnCode=r;
|
sl@0
|
462 |
}
|
sl@0
|
463 |
|
sl@0
|
464 |
TInt SOneOpTest::DoTest(TUnaryOperation anOperation, TRealX *aResult) const
|
sl@0
|
465 |
{
|
sl@0
|
466 |
TInt r=KErrNone;
|
sl@0
|
467 |
TRealX op;
|
sl@0
|
468 |
*aResult=(TRealX)iOperand;
|
sl@0
|
469 |
|
sl@0
|
470 |
switch(anOperation)
|
sl@0
|
471 |
{
|
sl@0
|
472 |
case EUnaryPlus:
|
sl@0
|
473 |
*aResult=+(*aResult);
|
sl@0
|
474 |
break;
|
sl@0
|
475 |
case EUnaryMinus:
|
sl@0
|
476 |
*aResult=-(*aResult);
|
sl@0
|
477 |
break;
|
sl@0
|
478 |
case EPreInc:
|
sl@0
|
479 |
++*aResult;
|
sl@0
|
480 |
break;
|
sl@0
|
481 |
case EPreDec:
|
sl@0
|
482 |
--*aResult;
|
sl@0
|
483 |
break;
|
sl@0
|
484 |
case EPostInc:
|
sl@0
|
485 |
op=(*aResult)++;
|
sl@0
|
486 |
if (!(SRealX(op)==iOperand))
|
sl@0
|
487 |
r=KErrGeneral;
|
sl@0
|
488 |
break;
|
sl@0
|
489 |
case EPostDec:
|
sl@0
|
490 |
op=(*aResult)--;
|
sl@0
|
491 |
if (!(SRealX(op)==iOperand))
|
sl@0
|
492 |
r=KErrGeneral;
|
sl@0
|
493 |
break;
|
sl@0
|
494 |
}
|
sl@0
|
495 |
return r;
|
sl@0
|
496 |
}
|
sl@0
|
497 |
|
sl@0
|
498 |
TInt OneOpTestThreadFunction(TAny *anInfo)
|
sl@0
|
499 |
{
|
sl@0
|
500 |
SOneOpTestThreadInfo *pI=(SOneOpTestThreadInfo *)anInfo;
|
sl@0
|
501 |
TInt r=pI->iTest->DoTest(pI->iOperation,pI->iResult);
|
sl@0
|
502 |
return r;
|
sl@0
|
503 |
}
|
sl@0
|
504 |
|
sl@0
|
505 |
void SOneOpTest::Test(TUnaryOperation anOperation) const
|
sl@0
|
506 |
{
|
sl@0
|
507 |
SOneOpTestThreadInfo info;
|
sl@0
|
508 |
TRealX result;
|
sl@0
|
509 |
info.iTest=this;
|
sl@0
|
510 |
info.iOperation=anOperation;
|
sl@0
|
511 |
info.iResult=&result;
|
sl@0
|
512 |
RThread t;
|
sl@0
|
513 |
TInt r=t.Create(_L("TestThread"),OneOpTestThreadFunction,0x1000,0x1000,0x100000,&info);
|
sl@0
|
514 |
test(r==KErrNone);
|
sl@0
|
515 |
t.SetPriority(EPriorityMore); // so we will not run again until thread terminates
|
sl@0
|
516 |
TRequestStatus s;
|
sl@0
|
517 |
t.Logon(s);
|
sl@0
|
518 |
t.Resume();
|
sl@0
|
519 |
User::WaitForRequest(s);
|
sl@0
|
520 |
TExitType exittype=t.ExitType();
|
sl@0
|
521 |
r=s.Int();
|
sl@0
|
522 |
CLOSE_AND_WAIT(t);
|
sl@0
|
523 |
SRealX sr(result);
|
sl@0
|
524 |
if (sr==iResult && r==iReturnCode)
|
sl@0
|
525 |
{
|
sl@0
|
526 |
if (anOperation>EUnaryMinus)
|
sl@0
|
527 |
{
|
sl@0
|
528 |
if (r==KErrNone && exittype==EExitKill)
|
sl@0
|
529 |
return;
|
sl@0
|
530 |
if (r!=KErrNone && exittype==EExitPanic)
|
sl@0
|
531 |
return;
|
sl@0
|
532 |
}
|
sl@0
|
533 |
else
|
sl@0
|
534 |
{
|
sl@0
|
535 |
if (exittype==EExitKill)
|
sl@0
|
536 |
return;
|
sl@0
|
537 |
}
|
sl@0
|
538 |
}
|
sl@0
|
539 |
|
sl@0
|
540 |
test.Printf(_L("Unary operation %d test failed\nop = %08X %08X %08X\n"),
|
sl@0
|
541 |
(TInt)anOperation,
|
sl@0
|
542 |
iOperand.iExpFlagSign, iOperand.iMantHigh, iOperand.iMantLow );
|
sl@0
|
543 |
test.Printf(_L("Result %08X %08X %08X\nReturn code %d Exit type %d\n"),
|
sl@0
|
544 |
sr.iExpFlagSign, sr.iMantHigh, sr.iMantLow, r, (TInt)exittype );
|
sl@0
|
545 |
test.Printf(_L("Correct result %08X %08X %08X\nCorrect return code %d\n"),
|
sl@0
|
546 |
iResult.iExpFlagSign, iResult.iMantHigh, iResult.iMantLow, iReturnCode );
|
sl@0
|
547 |
//test.Getch();
|
sl@0
|
548 |
test(0);
|
sl@0
|
549 |
}
|
sl@0
|
550 |
|
sl@0
|
551 |
STwoOpTest::STwoOpTest(const SRealX& o1, const SRealX& o2, const SRealX& res, TInt r)
|
sl@0
|
552 |
{
|
sl@0
|
553 |
iOperand1=o1;
|
sl@0
|
554 |
iOperand2=o2;
|
sl@0
|
555 |
iResult=res;
|
sl@0
|
556 |
iReturnCode=r;
|
sl@0
|
557 |
}
|
sl@0
|
558 |
|
sl@0
|
559 |
TInt STwoOpTest::DoTest(TBinaryOperation anOperation, TRealX *aResult, TBool aSwap) const
|
sl@0
|
560 |
{
|
sl@0
|
561 |
TInt r=KErrNone;
|
sl@0
|
562 |
TRealX op1, op2;
|
sl@0
|
563 |
if (aSwap)
|
sl@0
|
564 |
{
|
sl@0
|
565 |
op2=(TRealX)iOperand1;
|
sl@0
|
566 |
op1=(TRealX)iOperand2;
|
sl@0
|
567 |
*aResult=(TRealX)iOperand2;
|
sl@0
|
568 |
}
|
sl@0
|
569 |
else
|
sl@0
|
570 |
{
|
sl@0
|
571 |
op1=(TRealX)iOperand1;
|
sl@0
|
572 |
op2=(TRealX)iOperand2;
|
sl@0
|
573 |
*aResult=(TRealX)iOperand1;
|
sl@0
|
574 |
}
|
sl@0
|
575 |
|
sl@0
|
576 |
switch(anOperation)
|
sl@0
|
577 |
{
|
sl@0
|
578 |
case EAddEq:
|
sl@0
|
579 |
r=aResult->AddEq(op2);
|
sl@0
|
580 |
break;
|
sl@0
|
581 |
case ESubEq:
|
sl@0
|
582 |
r=aResult->SubEq(op2);
|
sl@0
|
583 |
break;
|
sl@0
|
584 |
case EMultEq:
|
sl@0
|
585 |
r=aResult->MultEq(op2);
|
sl@0
|
586 |
break;
|
sl@0
|
587 |
case EDivEq:
|
sl@0
|
588 |
r=aResult->DivEq(op2);
|
sl@0
|
589 |
break;
|
sl@0
|
590 |
case EAdd:
|
sl@0
|
591 |
r=op1.Add(*aResult,op2);
|
sl@0
|
592 |
break;
|
sl@0
|
593 |
case ESub:
|
sl@0
|
594 |
r=op1.Sub(*aResult,op2);
|
sl@0
|
595 |
break;
|
sl@0
|
596 |
case EMult:
|
sl@0
|
597 |
r=op1.Mult(*aResult,op2);
|
sl@0
|
598 |
break;
|
sl@0
|
599 |
case EDiv:
|
sl@0
|
600 |
r=op1.Div(*aResult,op2);
|
sl@0
|
601 |
break;
|
sl@0
|
602 |
case EPlusEq:
|
sl@0
|
603 |
*aResult+=op2;
|
sl@0
|
604 |
break;
|
sl@0
|
605 |
case EMinusEq:
|
sl@0
|
606 |
*aResult-=op2;
|
sl@0
|
607 |
break;
|
sl@0
|
608 |
case EStarEq:
|
sl@0
|
609 |
*aResult*=op2;
|
sl@0
|
610 |
break;
|
sl@0
|
611 |
case ESlashEq:
|
sl@0
|
612 |
*aResult/=op2;
|
sl@0
|
613 |
break;
|
sl@0
|
614 |
case EPlus:
|
sl@0
|
615 |
*aResult=op1+op2;
|
sl@0
|
616 |
break;
|
sl@0
|
617 |
case EMinus:
|
sl@0
|
618 |
*aResult=op1-op2;
|
sl@0
|
619 |
break;
|
sl@0
|
620 |
case EStar:
|
sl@0
|
621 |
*aResult=op1*op2;
|
sl@0
|
622 |
break;
|
sl@0
|
623 |
case ESlash:
|
sl@0
|
624 |
*aResult=op1/op2;
|
sl@0
|
625 |
break;
|
sl@0
|
626 |
}
|
sl@0
|
627 |
return r;
|
sl@0
|
628 |
}
|
sl@0
|
629 |
|
sl@0
|
630 |
TInt TwoOpTestThreadFunction(TAny *anInfo)
|
sl@0
|
631 |
{
|
sl@0
|
632 |
STwoOpTestThreadInfo *pI=(STwoOpTestThreadInfo *)anInfo;
|
sl@0
|
633 |
TInt r=pI->iTest->DoTest(pI->iOperation,pI->iResult,pI->iSwap);
|
sl@0
|
634 |
return r;
|
sl@0
|
635 |
}
|
sl@0
|
636 |
|
sl@0
|
637 |
void STwoOpTest::Test(TBinaryOperation anOperation, TBool aSwap) const
|
sl@0
|
638 |
{
|
sl@0
|
639 |
STwoOpTestThreadInfo info;
|
sl@0
|
640 |
TRealX result;
|
sl@0
|
641 |
info.iTest=this;
|
sl@0
|
642 |
info.iOperation=anOperation;
|
sl@0
|
643 |
info.iResult=&result;
|
sl@0
|
644 |
info.iSwap=aSwap;
|
sl@0
|
645 |
RThread t;
|
sl@0
|
646 |
TInt r=t.Create(_L("TestThread"),TwoOpTestThreadFunction,0x1000,0x1000,0x100000,&info);
|
sl@0
|
647 |
test(r==KErrNone);
|
sl@0
|
648 |
t.SetPriority(EPriorityMore); // so we will not run again until thread terminates
|
sl@0
|
649 |
TRequestStatus s;
|
sl@0
|
650 |
t.Logon(s);
|
sl@0
|
651 |
t.Resume();
|
sl@0
|
652 |
User::WaitForRequest(s);
|
sl@0
|
653 |
TExitType exittype=t.ExitType();
|
sl@0
|
654 |
r=s.Int();
|
sl@0
|
655 |
CLOSE_AND_WAIT(t);
|
sl@0
|
656 |
SRealX sr(result);
|
sl@0
|
657 |
if (anOperation>=EPlus && exittype==EExitPanic)
|
sl@0
|
658 |
{
|
sl@0
|
659 |
// if +,-,*,/ operation paniced, result will be lost
|
sl@0
|
660 |
sr=iResult;
|
sl@0
|
661 |
}
|
sl@0
|
662 |
if (sr==iResult && r==iReturnCode)
|
sl@0
|
663 |
{
|
sl@0
|
664 |
if (anOperation>=EPlusEq)
|
sl@0
|
665 |
{
|
sl@0
|
666 |
if (r==KErrNone && exittype==EExitKill)
|
sl@0
|
667 |
return;
|
sl@0
|
668 |
if (r!=KErrNone && exittype==EExitPanic)
|
sl@0
|
669 |
return;
|
sl@0
|
670 |
}
|
sl@0
|
671 |
else
|
sl@0
|
672 |
{
|
sl@0
|
673 |
if (exittype==EExitKill)
|
sl@0
|
674 |
return;
|
sl@0
|
675 |
}
|
sl@0
|
676 |
}
|
sl@0
|
677 |
|
sl@0
|
678 |
test.Printf(_L("Binary operation %d test failed\nop1 = %08X %08X %08X\nop2 = %08X %08X %08X\n"),
|
sl@0
|
679 |
(TInt)anOperation,
|
sl@0
|
680 |
iOperand1.iExpFlagSign, iOperand1.iMantHigh, iOperand1.iMantLow,
|
sl@0
|
681 |
iOperand2.iExpFlagSign, iOperand2.iMantHigh, iOperand2.iMantLow );
|
sl@0
|
682 |
test.Printf(_L("Result %08X %08X %08X\nReturn code %d Exit type %d\n"),
|
sl@0
|
683 |
sr.iExpFlagSign, sr.iMantHigh, sr.iMantLow, r, (TInt)exittype );
|
sl@0
|
684 |
test.Printf(_L("Correct result %08X %08X %08X\nCorrect return code %d\n"),
|
sl@0
|
685 |
iResult.iExpFlagSign, iResult.iMantHigh, iResult.iMantLow, iReturnCode );
|
sl@0
|
686 |
//test.Getch();
|
sl@0
|
687 |
test(0);
|
sl@0
|
688 |
}
|
sl@0
|
689 |
|
sl@0
|
690 |
SSpecialValueTest::SSpecialValueTest(const SRealX& op, TInt aResults)
|
sl@0
|
691 |
{
|
sl@0
|
692 |
iOperand=op;
|
sl@0
|
693 |
iIsZero=aResults & 8;
|
sl@0
|
694 |
iIsNaN=aResults & 4;
|
sl@0
|
695 |
iIsInfinite=aResults & 2;
|
sl@0
|
696 |
iIsFinite=aResults & 1;
|
sl@0
|
697 |
}
|
sl@0
|
698 |
|
sl@0
|
699 |
LOCAL_C TBool same(TBool a, TBool b)
|
sl@0
|
700 |
{
|
sl@0
|
701 |
return( (a && b) || (!a && !b) );
|
sl@0
|
702 |
}
|
sl@0
|
703 |
|
sl@0
|
704 |
void SSpecialValueTest::Test() const
|
sl@0
|
705 |
{
|
sl@0
|
706 |
TRealX x=(TRealX)iOperand;
|
sl@0
|
707 |
TBool isZero=x.IsZero();
|
sl@0
|
708 |
TBool isNaN=x.IsNaN();
|
sl@0
|
709 |
TBool isInfinite=x.IsInfinite();
|
sl@0
|
710 |
TBool isFinite=x.IsFinite();
|
sl@0
|
711 |
if ( same(isZero,iIsZero) && same(isNaN,iIsNaN) && same(isInfinite,iIsInfinite) && same(isFinite,iIsFinite) )
|
sl@0
|
712 |
return;
|
sl@0
|
713 |
test.Printf(_L("Special value test failed\nOperand %08X %08X %08X\n"),
|
sl@0
|
714 |
iOperand.iExpFlagSign, iOperand.iMantHigh, iOperand.iMantLow );
|
sl@0
|
715 |
test.Printf(_L("Results IsZero=%d, IsNaN=%d, IsInfinite=%d, IsFinite=%d "),
|
sl@0
|
716 |
isZero, isNaN, isInfinite, isFinite );
|
sl@0
|
717 |
test.Printf(_L("Correct results IsZero=%d, IsNaN=%d, IsInfinite=%d, IsFinite=%d "),
|
sl@0
|
718 |
iIsZero, iIsNaN, iIsInfinite, iIsFinite );
|
sl@0
|
719 |
//test.Getch();
|
sl@0
|
720 |
test(0);
|
sl@0
|
721 |
}
|
sl@0
|
722 |
|
sl@0
|
723 |
LOCAL_C void TestAssignConstruct()
|
sl@0
|
724 |
{
|
sl@0
|
725 |
TInt i;
|
sl@0
|
726 |
|
sl@0
|
727 |
// test default constructor
|
sl@0
|
728 |
TRealX z;
|
sl@0
|
729 |
SRealX sz(z);
|
sl@0
|
730 |
test(sz.iExpFlagSign==0);
|
sl@0
|
731 |
test(sz.iMantHigh==0);
|
sl@0
|
732 |
test(sz.iMantLow==0);
|
sl@0
|
733 |
|
sl@0
|
734 |
for (i=0; i<NumConvertFromIntTests; i++)
|
sl@0
|
735 |
{
|
sl@0
|
736 |
const SConvertFrom32BitTest *pT=&(ConvertFromIntTests[i]);
|
sl@0
|
737 |
pT->Test(EConstructInt);
|
sl@0
|
738 |
pT->Test(EAssignInt);
|
sl@0
|
739 |
pT->Test(ESetInt);
|
sl@0
|
740 |
}
|
sl@0
|
741 |
for (i=0; i<NumConvertFromUintTests; i++)
|
sl@0
|
742 |
{
|
sl@0
|
743 |
const SConvertFrom32BitTest *pT=&(ConvertFromUintTests[i]);
|
sl@0
|
744 |
pT->Test(EConstructUint);
|
sl@0
|
745 |
pT->Test(EAssignUint);
|
sl@0
|
746 |
pT->Test(ESetUint);
|
sl@0
|
747 |
}
|
sl@0
|
748 |
for (i=0; i<NumConvertFromInt64Tests; i++)
|
sl@0
|
749 |
{
|
sl@0
|
750 |
const SConvertFrom64BitTest *pT=&(ConvertFromInt64Tests[i]);
|
sl@0
|
751 |
pT->Test(EConstructInt64);
|
sl@0
|
752 |
pT->Test(EAssignInt64);
|
sl@0
|
753 |
pT->Test(ESetInt64);
|
sl@0
|
754 |
}
|
sl@0
|
755 |
for (i=0; i<NumConvertFromFloatTests; i++)
|
sl@0
|
756 |
{
|
sl@0
|
757 |
const SConvertFrom32BitTest *pT=&(ConvertFromFloatTests[i]);
|
sl@0
|
758 |
pT->Test(EConstructFloat);
|
sl@0
|
759 |
pT->Test(EAssignFloat);
|
sl@0
|
760 |
pT->Test(ESetFloat);
|
sl@0
|
761 |
}
|
sl@0
|
762 |
for (i=0; i<NumConvertFromDoubleTests; i++)
|
sl@0
|
763 |
{
|
sl@0
|
764 |
const SConvertFrom64BitTest *pT=&(ConvertFromDoubleTests[i]);
|
sl@0
|
765 |
pT->Test(EConstructDouble);
|
sl@0
|
766 |
pT->Test(EAssignDouble);
|
sl@0
|
767 |
pT->Test(ESetDouble);
|
sl@0
|
768 |
}
|
sl@0
|
769 |
}
|
sl@0
|
770 |
|
sl@0
|
771 |
LOCAL_C void TestConversions()
|
sl@0
|
772 |
{
|
sl@0
|
773 |
TInt i;
|
sl@0
|
774 |
for (i=0; i<NumConvertToIntTests; i++)
|
sl@0
|
775 |
{
|
sl@0
|
776 |
const SConvertTo32BitTest *pT=&(ConvertToIntTests[i]);
|
sl@0
|
777 |
pT->Test(EOperatorInt);
|
sl@0
|
778 |
}
|
sl@0
|
779 |
for (i=0; i<NumConvertToUintTests; i++)
|
sl@0
|
780 |
{
|
sl@0
|
781 |
const SConvertTo32BitTest *pT=&(ConvertToUintTests[i]);
|
sl@0
|
782 |
pT->Test(EOperatorUint);
|
sl@0
|
783 |
}
|
sl@0
|
784 |
for (i=0; i<NumConvertToInt64Tests; i++)
|
sl@0
|
785 |
{
|
sl@0
|
786 |
const SConvertTo64BitTest *pT=&(ConvertToInt64Tests[i]);
|
sl@0
|
787 |
pT->Test(EOperatorInt64);
|
sl@0
|
788 |
}
|
sl@0
|
789 |
for (i=0; i<NumConvertToFloatTests; i++)
|
sl@0
|
790 |
{
|
sl@0
|
791 |
const SConvertTo32BitTest *pT=&(ConvertToFloatTests[i]);
|
sl@0
|
792 |
pT->Test(EOperatorTReal32);
|
sl@0
|
793 |
pT->Test(EGetTReal32);
|
sl@0
|
794 |
}
|
sl@0
|
795 |
for (i=0; i<NumConvertToDoubleTests; i++)
|
sl@0
|
796 |
{
|
sl@0
|
797 |
const SConvertTo64BitTest *pT=&(ConvertToDoubleTests[i]);
|
sl@0
|
798 |
pT->Test(EOperatorTReal64);
|
sl@0
|
799 |
pT->Test(EGetTReal64);
|
sl@0
|
800 |
}
|
sl@0
|
801 |
}
|
sl@0
|
802 |
|
sl@0
|
803 |
LOCAL_C void TestSpecials()
|
sl@0
|
804 |
{
|
sl@0
|
805 |
TRealX x;
|
sl@0
|
806 |
SRealX sx;
|
sl@0
|
807 |
x.SetInfinite(EFalse);
|
sl@0
|
808 |
sx=x;
|
sl@0
|
809 |
test(sx.iExpFlagSign==0xFFFF0000);
|
sl@0
|
810 |
test(sx.iMantHigh==0x80000000);
|
sl@0
|
811 |
test(sx.iMantLow==0);
|
sl@0
|
812 |
x.SetZero();
|
sl@0
|
813 |
sx=x;
|
sl@0
|
814 |
test(sx.iExpFlagSign==0x00000000);
|
sl@0
|
815 |
x.SetInfinite(ETrue);
|
sl@0
|
816 |
sx=x;
|
sl@0
|
817 |
test(sx.iExpFlagSign==0xFFFF0001);
|
sl@0
|
818 |
test(sx.iMantHigh==0x80000000);
|
sl@0
|
819 |
test(sx.iMantLow==0);
|
sl@0
|
820 |
x.SetNaN();
|
sl@0
|
821 |
sx=x;
|
sl@0
|
822 |
test(sx.iExpFlagSign==0xFFFF0001);
|
sl@0
|
823 |
test(sx.iMantHigh==0xC0000000);
|
sl@0
|
824 |
test(sx.iMantLow==0);
|
sl@0
|
825 |
x.SetZero(ETrue);
|
sl@0
|
826 |
sx=x;
|
sl@0
|
827 |
test(sx.iExpFlagSign==0x00000001);
|
sl@0
|
828 |
|
sl@0
|
829 |
TInt i;
|
sl@0
|
830 |
for(i=0; i<NumSpecialValueTests; i++)
|
sl@0
|
831 |
{
|
sl@0
|
832 |
const SSpecialValueTest *pT=&(SpecialValueTests[i]);
|
sl@0
|
833 |
pT->Test();
|
sl@0
|
834 |
}
|
sl@0
|
835 |
}
|
sl@0
|
836 |
|
sl@0
|
837 |
LOCAL_C void TestUnaryOperators()
|
sl@0
|
838 |
{
|
sl@0
|
839 |
TInt i;
|
sl@0
|
840 |
for (i=0; i<NumUnaryPlusTests; i++)
|
sl@0
|
841 |
{
|
sl@0
|
842 |
const SOneOpTest *pT=&(UnaryPlusTests[i]);
|
sl@0
|
843 |
pT->Test(EUnaryPlus);
|
sl@0
|
844 |
}
|
sl@0
|
845 |
for (i=0; i<NumUnaryMinusTests; i++)
|
sl@0
|
846 |
{
|
sl@0
|
847 |
const SOneOpTest *pT=&(UnaryMinusTests[i]);
|
sl@0
|
848 |
pT->Test(EUnaryMinus);
|
sl@0
|
849 |
}
|
sl@0
|
850 |
for (i=0; i<NumIncTests; i++)
|
sl@0
|
851 |
{
|
sl@0
|
852 |
const SOneOpTest *pT=&(IncTests[i]);
|
sl@0
|
853 |
pT->Test(EPreInc);
|
sl@0
|
854 |
pT->Test(EPostInc);
|
sl@0
|
855 |
}
|
sl@0
|
856 |
for (i=0; i<NumDecTests; i++)
|
sl@0
|
857 |
{
|
sl@0
|
858 |
const SOneOpTest *pT=&(DecTests[i]);
|
sl@0
|
859 |
pT->Test(EPreDec);
|
sl@0
|
860 |
pT->Test(EPostDec);
|
sl@0
|
861 |
}
|
sl@0
|
862 |
}
|
sl@0
|
863 |
|
sl@0
|
864 |
LOCAL_C void TestAddition()
|
sl@0
|
865 |
{
|
sl@0
|
866 |
TInt i;
|
sl@0
|
867 |
for (i=0; i<NumAdditionTests; i++)
|
sl@0
|
868 |
{
|
sl@0
|
869 |
const STwoOpTest *pT=&(AdditionTests[i]);
|
sl@0
|
870 |
pT->Test(EAddEq,EFalse);
|
sl@0
|
871 |
pT->Test(EAddEq,ETrue);
|
sl@0
|
872 |
pT->Test(EAdd,EFalse);
|
sl@0
|
873 |
pT->Test(EAdd,ETrue);
|
sl@0
|
874 |
pT->Test(EPlusEq,EFalse);
|
sl@0
|
875 |
pT->Test(EPlusEq,ETrue);
|
sl@0
|
876 |
pT->Test(EPlus,EFalse);
|
sl@0
|
877 |
pT->Test(EPlus,ETrue);
|
sl@0
|
878 |
}
|
sl@0
|
879 |
for (i=0; i<NumBinaryOpNaNTests; i++)
|
sl@0
|
880 |
{
|
sl@0
|
881 |
const STwoOpTest *pT=&(BinaryOpNaNTests[i]);
|
sl@0
|
882 |
pT->Test(EAddEq,EFalse);
|
sl@0
|
883 |
pT->Test(EAddEq,ETrue);
|
sl@0
|
884 |
pT->Test(EAdd,EFalse);
|
sl@0
|
885 |
pT->Test(EAdd,ETrue);
|
sl@0
|
886 |
pT->Test(EPlusEq,EFalse);
|
sl@0
|
887 |
pT->Test(EPlusEq,ETrue);
|
sl@0
|
888 |
pT->Test(EPlus,EFalse);
|
sl@0
|
889 |
pT->Test(EPlus,ETrue);
|
sl@0
|
890 |
}
|
sl@0
|
891 |
}
|
sl@0
|
892 |
|
sl@0
|
893 |
LOCAL_C void TestMultiplication()
|
sl@0
|
894 |
{
|
sl@0
|
895 |
TInt i;
|
sl@0
|
896 |
for (i=0; i<NumMultiplicationTests; i++)
|
sl@0
|
897 |
{
|
sl@0
|
898 |
const STwoOpTest *pT=&(MultiplicationTests[i]);
|
sl@0
|
899 |
pT->Test(EMultEq,EFalse);
|
sl@0
|
900 |
pT->Test(EMultEq,ETrue);
|
sl@0
|
901 |
pT->Test(EMult,EFalse);
|
sl@0
|
902 |
pT->Test(EMult,ETrue);
|
sl@0
|
903 |
pT->Test(EStarEq,EFalse);
|
sl@0
|
904 |
pT->Test(EStarEq,ETrue);
|
sl@0
|
905 |
pT->Test(EStar,EFalse);
|
sl@0
|
906 |
pT->Test(EStar,ETrue);
|
sl@0
|
907 |
}
|
sl@0
|
908 |
for (i=0; i<NumBinaryOpNaNTests; i++)
|
sl@0
|
909 |
{
|
sl@0
|
910 |
const STwoOpTest *pT=&(BinaryOpNaNTests[i]);
|
sl@0
|
911 |
pT->Test(EMultEq,EFalse);
|
sl@0
|
912 |
pT->Test(EMultEq,ETrue);
|
sl@0
|
913 |
pT->Test(EMult,EFalse);
|
sl@0
|
914 |
pT->Test(EMult,ETrue);
|
sl@0
|
915 |
pT->Test(EStarEq,EFalse);
|
sl@0
|
916 |
pT->Test(EStarEq,ETrue);
|
sl@0
|
917 |
pT->Test(EStar,EFalse);
|
sl@0
|
918 |
pT->Test(EStar,ETrue);
|
sl@0
|
919 |
}
|
sl@0
|
920 |
}
|
sl@0
|
921 |
|
sl@0
|
922 |
LOCAL_C void TestDivision()
|
sl@0
|
923 |
{
|
sl@0
|
924 |
TInt i;
|
sl@0
|
925 |
for (i=0; i<NumDivisionTests; i++)
|
sl@0
|
926 |
{
|
sl@0
|
927 |
const STwoOpTest *pT=&(DivisionTests[i]);
|
sl@0
|
928 |
pT->Test(EDivEq,EFalse);
|
sl@0
|
929 |
pT->Test(EDiv,EFalse);
|
sl@0
|
930 |
pT->Test(ESlashEq,EFalse);
|
sl@0
|
931 |
pT->Test(ESlash,EFalse);
|
sl@0
|
932 |
}
|
sl@0
|
933 |
for (i=0; i<NumBinaryOpNaNTests; i++)
|
sl@0
|
934 |
{
|
sl@0
|
935 |
const STwoOpTest *pT=&(BinaryOpNaNTests[i]);
|
sl@0
|
936 |
pT->Test(EDivEq,EFalse);
|
sl@0
|
937 |
pT->Test(EDiv,EFalse);
|
sl@0
|
938 |
pT->Test(ESlashEq,EFalse);
|
sl@0
|
939 |
pT->Test(ESlash,EFalse);
|
sl@0
|
940 |
}
|
sl@0
|
941 |
}
|
sl@0
|
942 |
|
sl@0
|
943 |
LOCAL_C void TestComparison()
|
sl@0
|
944 |
{
|
sl@0
|
945 |
TInt i;
|
sl@0
|
946 |
for (i=0; i<NumComparisonTests; i++)
|
sl@0
|
947 |
{
|
sl@0
|
948 |
const SCompareTest *pT=&(ComparisonTests[i]);
|
sl@0
|
949 |
pT->Test();
|
sl@0
|
950 |
}
|
sl@0
|
951 |
}
|
sl@0
|
952 |
|
sl@0
|
953 |
|
sl@0
|
954 |
GLDEF_C TInt E32Main()
|
sl@0
|
955 |
//
|
sl@0
|
956 |
// Test TRealX
|
sl@0
|
957 |
//
|
sl@0
|
958 |
{
|
sl@0
|
959 |
|
sl@0
|
960 |
User::SetJustInTime(EFalse);
|
sl@0
|
961 |
test.Title();
|
sl@0
|
962 |
test.Start(_L("Assignment Operator and Constructors"));
|
sl@0
|
963 |
TestAssignConstruct();
|
sl@0
|
964 |
test.Next(_L("Conversions"));
|
sl@0
|
965 |
TestConversions();
|
sl@0
|
966 |
test.Next(_L("Setting and Checking Specials"));
|
sl@0
|
967 |
TestSpecials();
|
sl@0
|
968 |
test.Next(_L("Addition"));
|
sl@0
|
969 |
TestAddition();
|
sl@0
|
970 |
test.Next(_L("Multiplication"));
|
sl@0
|
971 |
TestMultiplication();
|
sl@0
|
972 |
test.Next(_L("Division"));
|
sl@0
|
973 |
TestDivision();
|
sl@0
|
974 |
test.Next(_L("Unary Operators"));
|
sl@0
|
975 |
TestUnaryOperators();
|
sl@0
|
976 |
test.Next(_L("Comparisons"));
|
sl@0
|
977 |
TestComparison();
|
sl@0
|
978 |
|
sl@0
|
979 |
test.End();
|
sl@0
|
980 |
return(KErrNone);
|
sl@0
|
981 |
}
|