os/kernelhwsrv/kerneltest/e32test/math/t_r64.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/math/t_r64.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,674 @@
     1.4 +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// e32test\math\t_r64.cpp
    1.18 +// T_R64.CPP - Test routines for TReal64
    1.19 +// Also note that these tests do not generally include testing of special values.  This is done
    1.20 +// in T_R96 tests and conversions are tested thoroughly, so explicit tests are unnecessary here.
    1.21 +// 
    1.22 +//
    1.23 +
    1.24 +#include "t_math.h"
    1.25 +#include "t_vals.h"
    1.26 +#include "t_real64.h"
    1.27 +
    1.28 +// Data for tests from T_R64DTA.cpp 
    1.29 +GLREF_D TReal64 addInput[];
    1.30 +GLREF_D TReal64 subInput[];
    1.31 +GLREF_D TReal64 multInput[];
    1.32 +GLREF_D TReal64 divInput[];
    1.33 +GLREF_D TReal64 divDenormalInput[];
    1.34 +GLREF_D TReal64 unaryInput[];
    1.35 +GLREF_D TReal64 incDecInput[];
    1.36 +GLREF_D TInt sizeAdd;
    1.37 +GLREF_D TInt sizeSub;
    1.38 +GLREF_D TInt sizeMult;
    1.39 +GLREF_D TInt sizeDiv;
    1.40 +GLREF_D TInt sizeDivDenormal;
    1.41 +GLREF_D TInt sizeUnary;
    1.42 +GLREF_D TInt sizeIncDec;
    1.43 +
    1.44 +#if defined (__WINS__) || defined (__X86__)
    1.45 +// Functions from EMGCC64.CPP
    1.46 +GLREF_C TReal64 __adddf3(TReal64 a1,TReal64 a2);
    1.47 +GLREF_C TReal64 __subdf3(TReal64 a1,TReal64 a2);
    1.48 +GLREF_C TReal64 __muldf3(TReal64 a1,TReal64 a2);
    1.49 +GLREF_C TReal64 __divdf3(TReal64 a1,TReal64 a2);
    1.50 +#endif
    1.51 +
    1.52 +// Special numbers for arithmetic tests
    1.53 +GLDEF_D TReal64 endsInFour;
    1.54 +GLDEF_D TReal64 arg1;
    1.55 +GLDEF_D TReal64 arg2;
    1.56 +GLDEF_D TReal64 arg3;
    1.57 +GLDEF_D const TReal64 KMinDenormalTReal64=5E-324;
    1.58 +GLDEF_D const TReal KNaNTReal=TReal(KNaNTReal64);
    1.59 +GLDEF_D const TReal KPosInfTReal=TReal(KPosInfTReal64);;
    1.60 +GLDEF_D const TReal KNegInfTReal=TReal(KNegInfTReal64);;
    1.61 +GLDEF_D const TReal KMinDenormalTReal=5E-324;
    1.62 +
    1.63 +enum TOrder
    1.64 +	{
    1.65 +	ELessThan,
    1.66 +	EEqual,
    1.67 +	EGreaterThan
    1.68 +	};
    1.69 +
    1.70 +LOCAL_D RTest test(_L("T_R64"));	
    1.71 +
    1.72 +#if defined (__WINS__) || defined (__X86__)
    1.73 +
    1.74 +LOCAL_C void testConstants()
    1.75 +//
    1.76 +// Checks that constants are defined as expected in WINS, in case low and high words are swapped
    1.77 +//
    1.78 +	{
    1.79 +
    1.80 +	test(TRealX(TReal32(KMinTReal32in64))==TRealX(KMinTReal32));
    1.81 +	test(TRealX(TReal32(KMaxTReal32in64))==TRealX(KMaxTReal32));
    1.82 +	}
    1.83 +
    1.84 +#endif
    1.85 +
    1.86 +LOCAL_C void initSpecialValues()
    1.87 +//
    1.88 +// Initialise special values, etc
    1.89 +//
    1.90 +	{
    1.91 +
    1.92 +	SReal64* p64=(SReal64*)&endsInFour;
    1.93 +	p64->sign=0;
    1.94 +	p64->exp=1020;
    1.95 +	p64->msm=0;
    1.96 +	p64->lsm=0x4;
    1.97 +
    1.98 +	p64=(SReal64*)&arg1;
    1.99 +	p64->sign=0;
   1.100 +	p64->exp=1075;
   1.101 +	p64->msm=0x20000;
   1.102 +	p64->lsm=0;
   1.103 +
   1.104 +	p64=(SReal64*)&arg2;
   1.105 +	p64->sign=0;
   1.106 +	p64->exp=1075;
   1.107 +	p64->msm=0;
   1.108 +	p64->lsm=0x2a;
   1.109 +
   1.110 +	p64=(SReal64*)&arg3;
   1.111 +	p64->sign=0;
   1.112 +	p64->exp=970;
   1.113 +	p64->msm=0xc71c7;
   1.114 +	p64->lsm=0x1c71c71c;
   1.115 +	}
   1.116 +	
   1.117 +LOCAL_C void testConvert()
   1.118 +//
   1.119 +// Test conversion from TReal to TReal64
   1.120 +// N.B. Conversions between TRealX and TReal64 are tested by t_r96.cpp 
   1.121 +//
   1.122 +	{
   1.123 +
   1.124 +	const TReal input[]=
   1.125 +		{
   1.126 +		KMaxTReal,KMinTReal,-KMaxTReal,-KMinTReal,
   1.127 +		1.7976931348622E+308,-1.7976931348622E+308,2.2250738585073E-308,-2.2250738585073E-308,
   1.128 +		KMaxTReal32inTReal,KMinTReal32inTReal,-KMaxTReal32inTReal,-KMinTReal32inTReal,
   1.129 +		0.0,64.5,-64.5,1.54E+180,-1.54E+180,4.72E-225,-4.72E-225,
   1.130 +		KNegZeroTReal,KPosInfTReal,KNegInfTReal,KMinDenormalTReal,
   1.131 +		1.2345E-318,-2.4682E-321,1.0E-323,-2.0E-308
   1.132 +		};
   1.133 +
   1.134 +	const TReal64 expect[]=
   1.135 +		{
   1.136 +		KMaxTReal64,KMinTReal64,-KMaxTReal64,-KMinTReal64,
   1.137 +		1.7976931348622E+308,-1.7976931348622E+308,2.2250738585073E-308,-2.2250738585073E-308,
   1.138 +		KMaxTReal32in64,KMinTReal32in64,-KMaxTReal32in64,-KMinTReal32in64,			
   1.139 +		0.0,64.5,-64.5,1.54E+180,-1.54E+180,4.72E-225,-4.72E-225,
   1.140 +		KNegZeroTReal64,KPosInfTReal64,KNegInfTReal64,KMinDenormalTReal64,
   1.141 +		1.2345E-318,-2.4682E-321,1.0E-323,-2.0E-308
   1.142 +		};		  
   1.143 +	
   1.144 +	TInt size = sizeof(input)/sizeof(TReal);
   1.145 +	TRealX f;
   1.146 +
   1.147 +	for (TInt ii=0; ii<size; ii++)
   1.148 +		{
   1.149 +		f=TRealX(TReal64(TRealX(input[ii])));
   1.150 +		test(f==TRealX(expect[ii]));
   1.151 +		}
   1.152 +
   1.153 +	// NaN
   1.154 +	TReal a=KNaNTReal;
   1.155 +//	TReal64 b=KNaNTReal64;
   1.156 +	f=TRealX(TReal64(TRealX(a)));
   1.157 +//	test(f!=TRealX(b));
   1.158 +	test(f.IsNaN());
   1.159 +	}
   1.160 +
   1.161 +LOCAL_C void testAdd()
   1.162 +//
   1.163 +//	Addition tests
   1.164 +//
   1.165 +	{
   1.166 +	TReal64 f,g,h,y;
   1.167 +	TRealX ff,gg,hh;
   1.168 +	
   1.169 +	for (TInt ii=0; ii<sizeAdd-1; ii++)
   1.170 +		{
   1.171 +		f=addInput[ii];
   1.172 +		g=addInput[ii+1];
   1.173 +		ff=TRealX(f);
   1.174 +		gg=TRealX(g);
   1.175 +		// Test commute
   1.176 +		test(f+g == g+f);
   1.177 +		// Test PC real addition using fp-hardware same as TRealX addition
   1.178 +		h=f+g;
   1.179 +		hh=ff+gg;
   1.180 +		y=(TReal64)hh;	// need to do this since TRealX has too much precision
   1.181 +		test(y==h);
   1.182 +		h=g+f;
   1.183 +		hh=gg+ff;
   1.184 +		y=(TReal64)hh;	// need to do this since TRealX has too much precision
   1.185 +		test(y==h);
   1.186 +		// Test hex-encoded constants for TReal64s generated on PC using fp-hardware same as 
   1.187 +		// TRealX addition
   1.188 +		test(*(TReal64*)&addArray[ii]==f+g);
   1.189 +		test(*(TReal64*)&addArray[ii]==g+f);
   1.190 +		// similarly to tests above ...
   1.191 +		h=g;
   1.192 +		hh=gg;
   1.193 +		h+=f;
   1.194 +		hh+=ff;
   1.195 +		test(h==(TReal64)hh);
   1.196 +		test(*(TReal64*)&addArray[ii]==h);
   1.197 +		//
   1.198 +		h=f;
   1.199 +		hh=ff;
   1.200 +		h+=g;
   1.201 +		hh+=gg;
   1.202 +		test(h==(TReal64)hh);
   1.203 +		test(*(TReal64*)&addArray[ii]==h);
   1.204 +		}
   1.205 +	}
   1.206 +
   1.207 +LOCAL_C void testSub()
   1.208 +//
   1.209 +// Subtraction tests - see notes in addition test above
   1.210 +//
   1.211 +	{
   1.212 +	TReal64 f,g,h;
   1.213 +	TRealX ff,gg,hh;
   1.214 +	
   1.215 +	for (TInt ii=0; ii<sizeSub-1; ii++)
   1.216 +		{
   1.217 +		f=subInput[ii];
   1.218 +		g=subInput[ii+1];
   1.219 +		ff=TRealX(f);
   1.220 +		gg=TRealX(g);
   1.221 +		//
   1.222 +		test(f-g == -(g-f));
   1.223 +		//
   1.224 +		test(TRealX(f-g)==ff-gg);
   1.225 +		test(TRealX(g-f)==gg-ff);
   1.226 +		test(*(TReal64*)&subArray[ii]==f-g);
   1.227 +		test(*(TReal64*)&subArray[ii]==-(g-f));
   1.228 +		//
   1.229 +		h=g;
   1.230 +		hh=gg;
   1.231 +		test(TRealX(h-=f)==(hh-=ff));
   1.232 +		test(TRealX(h)==hh);
   1.233 +		test(*(TReal64*)&subArray[ii]==-h);
   1.234 +		//
   1.235 +		h=f;
   1.236 +		hh=ff;
   1.237 +		test(TRealX(h-=g)==(hh-=gg));
   1.238 +		test(TRealX(h)==hh);
   1.239 +		test(*(TReal64*)&subArray[ii]==h);
   1.240 +		}
   1.241 +	}
   1.242 +
   1.243 +LOCAL_C void testMult()
   1.244 +//
   1.245 +//	Multiplication test
   1.246 +//
   1.247 +	{
   1.248 +	TReal64 f,g,h;
   1.249 +	TRealX ff,gg,hh;
   1.250 +	
   1.251 +	for (TInt ii=0; ii<sizeMult-1; ii++)
   1.252 +		{
   1.253 +		f=multInput[ii];
   1.254 +		g=multInput[ii+1];
   1.255 +		ff=TRealX(f);
   1.256 +		gg=TRealX(g);
   1.257 +		//
   1.258 +		test(f*g == g*f);
   1.259 +		//
   1.260 +		test(TRealX(f*g)==ff*gg);
   1.261 +		test(TRealX(g*f)==gg*ff);
   1.262 +		test(*(TReal64*)&multArray[ii]==f*g);
   1.263 +		test(*(TReal64*)&multArray[ii]==g*f);
   1.264 +		//
   1.265 +		h=f;		
   1.266 +		hh=ff;
   1.267 +		test(TRealX(h*=g)==(hh*=gg));
   1.268 +		test(TRealX(h)==hh);
   1.269 +		test(*(TReal64*)&multArray[ii]==h);
   1.270 +		//
   1.271 +		h=g;
   1.272 +		hh=gg;
   1.273 +		test(TRealX(h*=f)==(hh*=ff));
   1.274 +		test(TRealX(h)==hh);
   1.275 +		test(*(TReal64*)&multArray[ii]==h);
   1.276 +		}
   1.277 +	}
   1.278 +
   1.279 +LOCAL_C void testDiv()
   1.280 +//
   1.281 +//	Division tests
   1.282 +//
   1.283 +	{
   1.284 +	TReal64 f,g,h;
   1.285 +	TRealX ff,gg,hh;
   1.286 +	TInt count=0;
   1.287 +	
   1.288 +	// Panic (under ARM) - Divide by Zero - run in DEBUG build as a check only
   1.289 +	//f=1.0;
   1.290 +	//g=0.0;
   1.291 +	//f/=g;
   1.292 +
   1.293 +	for (TInt ii=0; ii<sizeDiv-1; ii++)
   1.294 +		{
   1.295 +		f=divInput[ii];
   1.296 +		g=divInput[ii+1];
   1.297 +		ff=TRealX(f);
   1.298 +		gg=TRealX(g);
   1.299 +		if (g!=0.0)
   1.300 +			{
   1.301 +			test(TRealX(f/g)==ff/gg);
   1.302 +			test(*(TReal64*)&divArray[count]==f/g);
   1.303 +			//
   1.304 +			h=f;
   1.305 +			hh=ff;
   1.306 +			test(TRealX(h/=g)==(hh/=gg));
   1.307 +			test(TRealX(h)==hh);
   1.308 +			test(*(TReal64*)&divArray[count]==h);
   1.309 +			++count;
   1.310 +			}							   
   1.311 +		if (f!=0.0)
   1.312 +			{
   1.313 +			test(TRealX(g/f)==gg/ff);
   1.314 +			//
   1.315 +			h=g;
   1.316 +			hh=gg;
   1.317 +			test(TRealX(h/=f)==(hh/=ff));
   1.318 +			test(TRealX(h)==hh);
   1.319 +			}
   1.320 +		}
   1.321 +
   1.322 +	gg=TRealX(arg2)/TRealX(arg3);
   1.323 +
   1.324 +	//Additional test
   1.325 +	f=3.999999999999999;
   1.326 +	g=KMinTReal64;
   1.327 +	ff=TRealX(f);
   1.328 +	gg=TRealX(g);
   1.329 +	test(TRealX(f/g)==ff/gg);
   1.330 +	h=f;
   1.331 +	test(TRealX(h/=g)==ff/gg);
   1.332 +	test(TRealX(h)==ff/gg);
   1.333 +	}
   1.334 +
   1.335 +#if defined (__WINS__) || defined (__X86__)
   1.336 +
   1.337 +LOCAL_C	 void testArithmeticExceptionRaising()
   1.338 +//
   1.339 +// Test that UP_GCC.CPP raise exceptions correctly by calling functions from EMGCC64.CPP which
   1.340 +// are copies of those in UP_GCC.CPP.  To be used in debugger only.
   1.341 +// Added by AnnW, December 1996
   1.342 +//
   1.343 +	{
   1.344 +	TReal64 f,g,h;
   1.345 +
   1.346 +	// Addition - possible errors are argument, overflow, or none
   1.347 +	// NB cannot achieve underflow now denormals in use
   1.348 +
   1.349 +	f=KNaNTReal64;
   1.350 +	h=__adddf3(f,f);	// argument
   1.351 +
   1.352 +	f=KMaxTReal64;
   1.353 +	h=__adddf3(f,f);	// overflow
   1.354 +	
   1.355 +	f=1.0;
   1.356 +	g=2.0;
   1.357 +	h=__adddf3(f,g);	// none
   1.358 +	test(h==3.0);
   1.359 +
   1.360 +	// Subtraction - possible errors are argumnet, overflow or none
   1.361 +	// NB cannot achieve underflow now denormals in use
   1.362 +
   1.363 +	f=KNaNTReal64;
   1.364 +	h=__subdf3(f,f);	// argument
   1.365 +
   1.366 +	f=KMaxTReal64;
   1.367 +	g=-KMaxTReal64;
   1.368 +	h=__subdf3(f,g);	// overflow
   1.369 +
   1.370 +	f=1.0;
   1.371 +	g=2.0;
   1.372 +	h=__subdf3(f,g);	// none
   1.373 +	test(h==-1.0);
   1.374 +
   1.375 +	// Multiplication - possible errors are argument, overflow, underflow or none
   1.376 +
   1.377 +	f=KNaNTReal64;
   1.378 +	h=__muldf3(f,f);	// argument
   1.379 +
   1.380 +	f=KMaxTReal64;
   1.381 +	g=2.0;
   1.382 +	h=__muldf3(f,g);	// overflow
   1.383 +
   1.384 +	f=KMinDenormalTReal64;
   1.385 +	g=0.1;
   1.386 +	h=__muldf3(f,g);	// underflow
   1.387 +
   1.388 +	f=1.0;
   1.389 +	g=2.0;
   1.390 +	h=__muldf3(f,g);	// none
   1.391 +	test(h==2.0);
   1.392 +
   1.393 +	// Division - possible errors are overflow, underflow, divide by zero, argument or none
   1.394 +
   1.395 +	f=KMaxTReal64;
   1.396 +	g=0.5;
   1.397 +	h=__divdf3(f,g);	// overflow
   1.398 +
   1.399 +	f=KMinDenormalTReal64;
   1.400 +	g=10.0;
   1.401 +	h=__divdf3(f,g);	// underflow
   1.402 +
   1.403 +	f=4.0;
   1.404 +	g=0.0;
   1.405 +	h=__divdf3(f,g);	// divide by zero
   1.406 +
   1.407 +	f=0.0;
   1.408 +	g=0.0;
   1.409 +	h=__divdf3(f,g);	// argument
   1.410 +
   1.411 +	f=1.0;
   1.412 +	g=2.0;
   1.413 +	h=__divdf3(f,g);	// none
   1.414 +	test(h==0.5);
   1.415 +	}
   1.416 +
   1.417 +#endif
   1.418 +
   1.419 +LOCAL_C void testUnary()
   1.420 +//
   1.421 +//	Unary operator tests
   1.422 +//
   1.423 +	{
   1.424 +	TReal64 f;
   1.425 +	TRealX g;
   1.426 +
   1.427 +	for (TInt ii=0; ii<sizeUnary-1; ii++)
   1.428 +		{
   1.429 +		f=unaryInput[ii];
   1.430 +		g=TRealX(f);
   1.431 +		test(TRealX(-f)==-g);
   1.432 +		test(TRealX(-f)==TRealX(0-f));
   1.433 +		test(TRealX(+f)==g);
   1.434 +		test(TRealX(+f)==TRealX(0+f));
   1.435 +		test(*(TReal64*)&unaryArray[ii]==-f);
   1.436 +		}
   1.437 +	}
   1.438 +
   1.439 +LOCAL_C void testEqualities(const TReal& aA, TOrder aOrder, const TReal& aB)
   1.440 +//
   1.441 +//	Test equality/inequality functions on aA and aB
   1.442 +//	aOrder specifies the operand's relative sizes
   1.443 +//
   1.444 +	{
   1.445 +	//	Tautologies
   1.446 +	test((aA>aA) ==FALSE);
   1.447 +	test((aA<aA) ==FALSE);
   1.448 +	test((aA>=aA)==TRUE);
   1.449 +	test((aA<=aA)==TRUE);
   1.450 +	test((aA==aA)==TRUE);
   1.451 +	test((aA!=aA)==FALSE);
   1.452 +
   1.453 +	if (aOrder!=EEqual)
   1.454 +		{
   1.455 +		test((aA==aB)==FALSE);
   1.456 +  		test((aA!=aB)==TRUE);
   1.457 +		}
   1.458 +
   1.459 +	if (aOrder==ELessThan)
   1.460 +		{
   1.461 +		test((aA<aB) ==TRUE);
   1.462 +		test((aA<=aB)==TRUE);
   1.463 +		test((aA>aB) ==FALSE);
   1.464 +		test((aA>=aB)==FALSE);
   1.465 +		}
   1.466 +
   1.467 +	if (aOrder==EEqual)
   1.468 +		{
   1.469 +		test((aA==aB)==TRUE);
   1.470 +		test((aA!=aB)==FALSE);
   1.471 +		test((aA>=aB)==TRUE);
   1.472 +		test((aA<=aB)==TRUE);
   1.473 +		test((aA>aB)==FALSE);
   1.474 +		test((aA<aB)==FALSE);
   1.475 +		}
   1.476 +
   1.477 +	if (aOrder==EGreaterThan)
   1.478 +		{
   1.479 +		test((aA>aB) ==TRUE);
   1.480 +		test((aA>=aB)==TRUE);
   1.481 +		test((aA<aB) ==FALSE);
   1.482 +		test((aA<=aB)==FALSE);
   1.483 +		}
   1.484 +	}
   1.485 +	 
   1.486 +LOCAL_C void testEqualities()
   1.487 +//
   1.488 +//	Test >, <, >=, <=, ==, !=
   1.489 +//
   1.490 +	{
   1.491 +	TInt i, size;
   1.492 +	TReal64 lessThanMax = KMaxTReal64-TReal64(1.0E+294);
   1.493 +	TReal64 greaterThanMin = TReal64(2.225075E-308);
   1.494 +	TReal64 zero(0.0);
   1.495 +	
   1.496 +	TReal64 positive[] =
   1.497 +	{KMinTReal64,5.3824705392348592E-138,1.0,2387501,5.3824705392348592E+138,KMaxTReal64};
   1.498 +
   1.499 +	TReal64 large[] =
   1.500 +	{2.0,KMaxTReal64,-lessThanMax,greaterThanMin,-KMinTReal64,10.40584821945060,-10.40584821945058,
   1.501 +	1.244334567201E+105,1.244334567201E+105,-1.3420344230402E-106,132435.97865,5.0E-16,9.6,-8.0}; 
   1.502 +	
   1.503 +	TReal64 small[] =
   1.504 +	{1.0,lessThanMax,-KMaxTReal64,KMinTReal64,-greaterThanMin,10.40584821945058,-10.40584821945060,
   1.505 +	50E-100,1.244334567201E+104,-5.03824705392348592E+58,-132435.97865,-5.1E-16,8.0,-9.6};
   1.506 +	
   1.507 +	TReal64 equal[] =							  // Same as large[]
   1.508 +	{2.0,KMaxTReal64,-lessThanMax,greaterThanMin,-KMinTReal64,10.40584821945060,-10.40584821945058,
   1.509 +	1.244334567201E+105,1.244334567201E+105,-1.3420344230402E-106,132435.97865,5.0E-16,9.6,-8.0}; 
   1.510 +
   1.511 +	// Tests with zero
   1.512 +
   1.513 +	size = sizeof(positive)/sizeof(TReal64);
   1.514 +	
   1.515 +	test.Start(_L("Zero"));
   1.516 +	testEqualities(zero, EEqual, zero);
   1.517 +	for (i=0; i<size; i++)
   1.518 +		{
   1.519 +		testEqualities(positive[i], EGreaterThan, zero);
   1.520 +		testEqualities(-positive[i], ELessThan, zero);
   1.521 +		testEqualities(zero, ELessThan, positive[i]);
   1.522 +		testEqualities(zero, EGreaterThan, -positive[i]);
   1.523 +		}
   1.524 +
   1.525 +	// Test boundary and other numbers
   1.526 +	
   1.527 +	size = sizeof(large)/sizeof(TReal64);
   1.528 +	
   1.529 +	test.Next(_L("Nonzero"));
   1.530 +	for (i=0; i<size; i++)
   1.531 +		{
   1.532 +		testEqualities(large[i], EGreaterThan, small[i]);
   1.533 +		testEqualities(small[i], ELessThan, large[i]);
   1.534 +		testEqualities(large[i], EEqual, equal[i]);
   1.535 +		}
   1.536 +
   1.537 +	test.End();
   1.538 +	}
   1.539 +
   1.540 +LOCAL_C void testIncDec()
   1.541 +//
   1.542 +//	Test Pre/Post-increment/decrement
   1.543 +//
   1.544 +	{
   1.545 +	TInt ii;
   1.546 +	TReal64 f;
   1.547 +	TRealX g;
   1.548 +
   1.549 +	test.Start(_L("Pre-increment"));
   1.550 +	
   1.551 +	for (ii=0; ii<sizeIncDec; ii++)
   1.552 +		{
   1.553 +		f=incDecInput[ii];
   1.554 +		g=TRealX(f);
   1.555 +		test(TRealX(f)==g);
   1.556 +		test(TRealX(++f)==(++g));
   1.557 +		test(*(TReal64*)&preIncArray1[ii]==f);
   1.558 +		test(TRealX(f)==g);
   1.559 +		test(TRealX(++f)==(++g));
   1.560 +		test(*(TReal64*)&preIncArray2[ii]==f);
   1.561 +		test(TRealX(f)==g);
   1.562 +		}
   1.563 +	
   1.564 +	test.Next(_L("Post-increment"));
   1.565 +
   1.566 +	for (ii=0; ii<sizeIncDec; ii++)
   1.567 +		{
   1.568 +		f=incDecInput[ii];
   1.569 +		g=TRealX(f);
   1.570 +		test(TRealX(f)==g);
   1.571 +		test(TRealX(f++)==(g++));
   1.572 +		test(*(TReal64*)&postIncArray1[ii]==f);
   1.573 +		test(TRealX(f)==g);
   1.574 +		test(TRealX(f++)==(g++));
   1.575 +		test(*(TReal64*)&postIncArray2[ii]==f);
   1.576 +		test(TRealX(f)==g);
   1.577 +		}
   1.578 +	
   1.579 +	test.Next(_L("Pre-decrement"));
   1.580 +
   1.581 +	for (ii=0; ii<sizeIncDec; ii++)
   1.582 +		{
   1.583 +		f=incDecInput[ii];
   1.584 +		g=TRealX(f);
   1.585 +		test(TRealX(f)==g);
   1.586 +		test(TRealX(--f)==(--g));
   1.587 +		test(*(TReal64*)&preDecArray1[ii]==f);
   1.588 +		test(TRealX(f)==g);
   1.589 +		test(TRealX(--f)==(--g));
   1.590 +		test(*(TReal64*)&preDecArray2[ii]==f);
   1.591 +		test(TRealX(f)==g);
   1.592 +		}
   1.593 +	
   1.594 +	test.Next(_L("Post-decrement"));
   1.595 +
   1.596 +	for	(ii=0; ii<sizeIncDec; ii++)
   1.597 +		{
   1.598 +		f=incDecInput[ii];
   1.599 +		g=TRealX(f);
   1.600 +		test(TRealX(f)==g);
   1.601 +		test(TRealX(f--)==(g--));
   1.602 +		test(*(TReal64*)&postDecArray1[ii]==f);
   1.603 +		test(TRealX(f)==g);
   1.604 +		test(TRealX(f--)==(g--));
   1.605 +		test(*(TReal64*)&postDecArray2[ii]==f);
   1.606 +		test(TRealX(f)==g);
   1.607 +		}
   1.608 +	test.End();
   1.609 +	}
   1.610 +
   1.611 +LOCAL_C void _matherr(TExcType aType)
   1.612 +//
   1.613 +// Dummy function to handle exceptions
   1.614 +//
   1.615 +	{
   1.616 +
   1.617 +	test.Printf(_L("_matherr: Exception type %u handled\n"),TUint(aType));
   1.618 +	}
   1.619 +
   1.620 +
   1.621 +GLDEF_C TInt E32Main()
   1.622 +//
   1.623 +//	Test TReal64
   1.624 +//
   1.625 +    {	  
   1.626 +
   1.627 +	test.Title();
   1.628 +
   1.629 +#if defined (__X86__)
   1.630 +	TInt16 cw=0;
   1.631 +	_asm fstcw cw;
   1.632 +	test.Printf(_L("control word = 0x%x\n"),cw);
   1.633 +	cw=0x27f;	// WINS value
   1.634 +	_asm fldcw cw;
   1.635 +#endif
   1.636 +
   1.637 +	// Set exceptions to be handled
   1.638 +	RThread myThread;
   1.639 +	myThread.SetExceptionHandler(_matherr,KExceptionFpe);
   1.640 +
   1.641 +	initSpecialValues();
   1.642 +
   1.643 +#if defined (__WINS__) || defined (__X86__)
   1.644 +	test.Start(_L("Checking double words not swapped..."));
   1.645 +	testConstants();
   1.646 +	test.Next(_L("Conversion from TReal to TReal64"));
   1.647 +	testConvert();
   1.648 +#else
   1.649 +	test.Start(_L("Conversion from TReal to TReal64"));
   1.650 +	testConvert();
   1.651 +#endif
   1.652 +	test.Next(_L("Conversion from TReal to TReal64"));
   1.653 +	testConvert();
   1.654 +	test.Next(_L("Addition"));
   1.655 +	testAdd();
   1.656 +	test.Next(_L("Subtraction"));
   1.657 +	testSub();
   1.658 +	test.Next(_L("Multiplication"));
   1.659 +	testMult();
   1.660 +	test.Next(_L("Division"));
   1.661 +	testDiv();
   1.662 +#if defined (__WINS__) || defined (__X86__)
   1.663 +	test.Next(_L("Arithmetic which emulates UP_GCC and raises an exception"));
   1.664 +	testArithmeticExceptionRaising();
   1.665 +#endif
   1.666 +	test.Next(_L("Unary Operations"));
   1.667 +	testUnary();
   1.668 +	test.Next(_L("Equalities and Inequalities"));
   1.669 +	testEqualities();
   1.670 +	test.Next(_L("Increment and Decrement"));
   1.671 +	testIncDec();
   1.672 +
   1.673 +	test.End();
   1.674 +	return(KErrNone);
   1.675 +    }
   1.676 +
   1.677 +