diff -r 000000000000 -r bde4ae8d615e os/kernelhwsrv/kerneltest/e32test/math/t_r64.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/os/kernelhwsrv/kerneltest/e32test/math/t_r64.cpp Fri Jun 15 03:10:57 2012 +0200 @@ -0,0 +1,674 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of the License "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// e32test\math\t_r64.cpp +// T_R64.CPP - Test routines for TReal64 +// Also note that these tests do not generally include testing of special values. This is done +// in T_R96 tests and conversions are tested thoroughly, so explicit tests are unnecessary here. +// +// + +#include "t_math.h" +#include "t_vals.h" +#include "t_real64.h" + +// Data for tests from T_R64DTA.cpp +GLREF_D TReal64 addInput[]; +GLREF_D TReal64 subInput[]; +GLREF_D TReal64 multInput[]; +GLREF_D TReal64 divInput[]; +GLREF_D TReal64 divDenormalInput[]; +GLREF_D TReal64 unaryInput[]; +GLREF_D TReal64 incDecInput[]; +GLREF_D TInt sizeAdd; +GLREF_D TInt sizeSub; +GLREF_D TInt sizeMult; +GLREF_D TInt sizeDiv; +GLREF_D TInt sizeDivDenormal; +GLREF_D TInt sizeUnary; +GLREF_D TInt sizeIncDec; + +#if defined (__WINS__) || defined (__X86__) +// Functions from EMGCC64.CPP +GLREF_C TReal64 __adddf3(TReal64 a1,TReal64 a2); +GLREF_C TReal64 __subdf3(TReal64 a1,TReal64 a2); +GLREF_C TReal64 __muldf3(TReal64 a1,TReal64 a2); +GLREF_C TReal64 __divdf3(TReal64 a1,TReal64 a2); +#endif + +// Special numbers for arithmetic tests +GLDEF_D TReal64 endsInFour; +GLDEF_D TReal64 arg1; +GLDEF_D TReal64 arg2; +GLDEF_D TReal64 arg3; +GLDEF_D const TReal64 KMinDenormalTReal64=5E-324; +GLDEF_D const TReal KNaNTReal=TReal(KNaNTReal64); +GLDEF_D const TReal KPosInfTReal=TReal(KPosInfTReal64);; +GLDEF_D const TReal KNegInfTReal=TReal(KNegInfTReal64);; +GLDEF_D const TReal KMinDenormalTReal=5E-324; + +enum TOrder + { + ELessThan, + EEqual, + EGreaterThan + }; + +LOCAL_D RTest test(_L("T_R64")); + +#if defined (__WINS__) || defined (__X86__) + +LOCAL_C void testConstants() +// +// Checks that constants are defined as expected in WINS, in case low and high words are swapped +// + { + + test(TRealX(TReal32(KMinTReal32in64))==TRealX(KMinTReal32)); + test(TRealX(TReal32(KMaxTReal32in64))==TRealX(KMaxTReal32)); + } + +#endif + +LOCAL_C void initSpecialValues() +// +// Initialise special values, etc +// + { + + SReal64* p64=(SReal64*)&endsInFour; + p64->sign=0; + p64->exp=1020; + p64->msm=0; + p64->lsm=0x4; + + p64=(SReal64*)&arg1; + p64->sign=0; + p64->exp=1075; + p64->msm=0x20000; + p64->lsm=0; + + p64=(SReal64*)&arg2; + p64->sign=0; + p64->exp=1075; + p64->msm=0; + p64->lsm=0x2a; + + p64=(SReal64*)&arg3; + p64->sign=0; + p64->exp=970; + p64->msm=0xc71c7; + p64->lsm=0x1c71c71c; + } + +LOCAL_C void testConvert() +// +// Test conversion from TReal to TReal64 +// N.B. Conversions between TRealX and TReal64 are tested by t_r96.cpp +// + { + + const TReal input[]= + { + KMaxTReal,KMinTReal,-KMaxTReal,-KMinTReal, + 1.7976931348622E+308,-1.7976931348622E+308,2.2250738585073E-308,-2.2250738585073E-308, + KMaxTReal32inTReal,KMinTReal32inTReal,-KMaxTReal32inTReal,-KMinTReal32inTReal, + 0.0,64.5,-64.5,1.54E+180,-1.54E+180,4.72E-225,-4.72E-225, + KNegZeroTReal,KPosInfTReal,KNegInfTReal,KMinDenormalTReal, + 1.2345E-318,-2.4682E-321,1.0E-323,-2.0E-308 + }; + + const TReal64 expect[]= + { + KMaxTReal64,KMinTReal64,-KMaxTReal64,-KMinTReal64, + 1.7976931348622E+308,-1.7976931348622E+308,2.2250738585073E-308,-2.2250738585073E-308, + KMaxTReal32in64,KMinTReal32in64,-KMaxTReal32in64,-KMinTReal32in64, + 0.0,64.5,-64.5,1.54E+180,-1.54E+180,4.72E-225,-4.72E-225, + KNegZeroTReal64,KPosInfTReal64,KNegInfTReal64,KMinDenormalTReal64, + 1.2345E-318,-2.4682E-321,1.0E-323,-2.0E-308 + }; + + TInt size = sizeof(input)/sizeof(TReal); + TRealX f; + + for (TInt ii=0; iiaA) ==FALSE); + test((aA=aA)==TRUE); + test((aA<=aA)==TRUE); + test((aA==aA)==TRUE); + test((aA!=aA)==FALSE); + + if (aOrder!=EEqual) + { + test((aA==aB)==FALSE); + test((aA!=aB)==TRUE); + } + + if (aOrder==ELessThan) + { + test((aAaB) ==FALSE); + test((aA>=aB)==FALSE); + } + + if (aOrder==EEqual) + { + test((aA==aB)==TRUE); + test((aA!=aB)==FALSE); + test((aA>=aB)==TRUE); + test((aA<=aB)==TRUE); + test((aA>aB)==FALSE); + test((aAaB) ==TRUE); + test((aA>=aB)==TRUE); + test((aA, <, >=, <=, ==, != +// + { + TInt i, size; + TReal64 lessThanMax = KMaxTReal64-TReal64(1.0E+294); + TReal64 greaterThanMin = TReal64(2.225075E-308); + TReal64 zero(0.0); + + TReal64 positive[] = + {KMinTReal64,5.3824705392348592E-138,1.0,2387501,5.3824705392348592E+138,KMaxTReal64}; + + TReal64 large[] = + {2.0,KMaxTReal64,-lessThanMax,greaterThanMin,-KMinTReal64,10.40584821945060,-10.40584821945058, + 1.244334567201E+105,1.244334567201E+105,-1.3420344230402E-106,132435.97865,5.0E-16,9.6,-8.0}; + + TReal64 small[] = + {1.0,lessThanMax,-KMaxTReal64,KMinTReal64,-greaterThanMin,10.40584821945058,-10.40584821945060, + 50E-100,1.244334567201E+104,-5.03824705392348592E+58,-132435.97865,-5.1E-16,8.0,-9.6}; + + TReal64 equal[] = // Same as large[] + {2.0,KMaxTReal64,-lessThanMax,greaterThanMin,-KMinTReal64,10.40584821945060,-10.40584821945058, + 1.244334567201E+105,1.244334567201E+105,-1.3420344230402E-106,132435.97865,5.0E-16,9.6,-8.0}; + + // Tests with zero + + size = sizeof(positive)/sizeof(TReal64); + + test.Start(_L("Zero")); + testEqualities(zero, EEqual, zero); + for (i=0; i