First public contribution.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // f32test\math\t_gen32.cpp
15 // Generates files to be used in testing whether arithmetic in TReal32 gives
16 // exactly the same results using the MSDEV complier as on the rack.
23 #include "../server/t_server.h"
27 // Some symbols generated by the VC++ compiler for floating point stuff.
30 GLDEF_D TInt _adj_fdiv_m32;
34 GLDEF_D RTest test(_L("T_GEN32"));
37 LOCAL_D const TFileName fileName32 = _L("T_REAL32.H");
39 LOCAL_D const TFileName pathName = _L("C:\\E32-MATH\\");
40 LOCAL_D TBuf<0x100> buf;
41 LOCAL_D TBuf8<0x100> buf8;
43 // Data for tests from T_R32DTA.cpp
44 GLREF_D TReal32 addInput[];
45 GLREF_D TReal32 subInput[];
46 GLREF_D TReal32 multInput[];
47 GLREF_D TReal32 divInput[];
48 //GLREF_D TApprox32 subApprox[];
49 GLREF_D TReal32 unaryInput[];
50 GLREF_D TReal32 incDecInput[];
53 GLREF_D TInt sizeMult;
55 //GLREF_D TInt sizeSubApprox;
56 GLREF_D TInt sizeUnary;
57 GLREF_D TInt sizeIncDec;
59 LOCAL_C void appendStart()
61 f.Write(_L8("// Generated by \\E32\\TMATH\\T_GEN32.MAK\n\n"));
62 f.Write(_L8("#include <e32std.h>\n\n"));
63 f.Write(_L8("#if defined(__WINS__)\n#include \"t_vals.hwg\"\n"));
64 f.Write(_L8("#else\n#include \"t_vals.hag\"\n#endif\n"));
67 LOCAL_C void appendArrayName32(TPtrC aName)
70 buf.AppendFormat(_L("const TInt32x %S[] = \n{\n"),&aName);
75 LOCAL_C void appendValue32(TReal32* aVal)
78 buf.AppendFormat(_L(" TInt32x(0x%x),\n"),*(TUint32*)aVal);
83 LOCAL_C void appendArrayTerm()
89 LOCAL_C void createAddArray()
91 // Writes an array of results of additions to the header file
97 appendArrayName32(_L("addArray"));
98 for (ii=0; ii<sizeAdd-1; ii++)
100 ff=addInput[ii]+addInput[ii+1];
106 LOCAL_C void createSubArray()
108 // Writes an array of results of subtractions to the header file
114 appendArrayName32(_L("subArray"));
115 for (ii=0; ii<sizeSub-1; ii++)
117 ff=subInput[ii]-subInput[ii+1];
123 appendArrayName32(_L("subApproxArray"));
124 for (ii=0; ii<sizeSubApprox; ii++)
126 ff=subApprox[ii].f-subApprox[ii].g;
133 LOCAL_C void createMultArray()
135 // Writes an array of results of multiplications to the header file
141 appendArrayName32(_L("multArray"));
142 for (ii=0; ii<sizeMult-1; ii++)
144 ff=multInput[ii]*multInput[ii+1];
150 LOCAL_C void createDivArray()
152 // Writes an array of results of divisions to the header file
158 appendArrayName32(_L("divArray"));
159 for (ii=0; ii<sizeDiv-1; ii++)
161 if (divInput[ii+1]!=0)
163 ff=divInput[ii]/divInput[ii+1];
170 LOCAL_C void createUnaryArray()
172 // Writes an array of results of unary operations to the header file
177 appendArrayName32(_L("unaryArray"));
178 for (TInt ii=0; ii<sizeUnary; ii++)
186 LOCAL_C void createIncDecArrays()
188 // Writes an array of results of pre and post increment and decrement operations to the
195 appendArrayName32(_L("preIncArray1"));
196 for (ii=0; ii<sizeIncDec; ii++)
204 appendArrayName32(_L("preIncArray2"));
205 for (ii=0; ii<sizeIncDec; ii++)
214 appendArrayName32(_L("preDecArray1"));
215 for (ii=0; ii<sizeIncDec; ii++)
223 appendArrayName32(_L("preDecArray2"));
224 for (ii=0; ii<sizeIncDec; ii++)
233 appendArrayName32(_L("postIncArray1"));
234 for (ii=0; ii<sizeIncDec; ii++)
242 appendArrayName32(_L("postIncArray2"));
243 for (ii=0; ii<sizeIncDec; ii++)
252 appendArrayName32(_L("postDecArray1"));
253 for (ii=0; ii<sizeIncDec; ii++)
261 appendArrayName32(_L("postDecArray2"));
262 for (ii=0; ii<sizeIncDec; ii++)
272 LOCAL_C void createArrays()
274 // Create and append to header file all arrays required for T_R32.CPP tests
282 createIncDecArrays();
285 GLDEF_C void CallTestsL(void)
287 // Generate TReal32s (and special values if required) and write to header files
294 msg=_L("Generating Maths constants to header files:\n ");
299 test.Next(_L("Making directory"));
300 TInt r=TheFs.MkDirAll(pathName);
301 test(r==KErrNone || r==KErrAlreadyExists);
302 test(TheFs.SetSessionPath(pathName)==KErrNone);
304 test(f.Replace(TheFs,fileName32,EFileWrite)==KErrNone);
305 test.Next(_L("Generating TReal32s"));