Changes in X11DRV_KEYBOARD_DetectLayout in order to implement Russian
[wine/multimedia.git] / libtest / vartest.c
blobbe5fed21b2d669d6a5256dc3982468b3f6aaee98
1 /*
2 * VARIANT test program
4 * Copyright 1998 Jean-Claude Cote
6 * The purpose of this program is validate the implementation
7 * of the APIs related to VARIANTs. The validation is done
8 * by comparing the results given by the Windows implementation
9 * versus the Wine implementation.
11 * This program tests the creation/coercion/destruction of VARIANTs.
13 * The program does not currently test any API that takes
14 * arguments of type: IDispatch, IUnknown, DECIMAL, CURRENCY.
16 * Since the purpose of this program is to compare the results
17 * from Windows and Wine it is written so that with a simple
18 * define it can be compiled either in Windows or Linux.
21 * NOTES
22 * - The Variant structure in Windows has a non-named union. This means
23 * the member of the union are accessible simply by doing pVariant->pfltVal.
24 * With gcc it is not possible to have non-named union so it has been named
25 * 'u'. So it's members are accessible using this name like so
26 * pVariant->u.pfltVal. So if this program is compiled in Windows
27 * the references to 'u' will need to be take out of this file.
29 * - Also the printf is a little different so the format specifiers may
30 * need to be tweaked if this file is compile in Windows.
31 * Printf is also different in that it continues printing numbers
32 * even after there is no more significative digits left to print. These
33 * number are garbage and in windows they are set to zero but not
34 * on Linux.
36 * - The VarDateFromStr is not implemented yet.
38 * - The date and floating point format may not be the exact same format has the one in
39 * windows depending on what the Internatinal setting are in windows.
45 #include <stdio.h>
46 #include <malloc.h>
47 #include <windows.h>
48 #include <winerror.h>
49 #include <winnt.h>
51 #include <oleauto.h>
53 #include <math.h>
54 #include <float.h>
55 #include <time.h>
57 #if WINDOWS
58 #include <wtypes.h>
59 #else
60 #include <windef.h>
61 #endif
64 #ifdef WINDOWS
65 #else
66 #include <debugstr.h>
67 extern LPWSTR HEAP_strdupAtoW( HANDLE heap, DWORD flags, LPCSTR str );
68 #endif
71 static const int MAX_BUFFER = 1024;
74 #ifdef WINDOWS
75 char* WtoA( OLECHAR* p )
77 int i = 0;
78 char* pc = (char *)malloc( MAX_BUFFER*sizeof(char) );
79 pc[0] = '\"';
80 pc++;
81 i = wcstombs( pc, p, MAX_BUFFER );
82 if( i < MAX_BUFFER-1 )
84 pc[i] = '\"';
85 pc[i+1] = '\0';
87 pc--;
88 return pc;
91 OLECHAR* AtoW( char* p )
93 int i = 0;
94 OLECHAR* pwc = (OLECHAR *)malloc( MAX_BUFFER*sizeof(OLECHAR) );
95 i = mbstowcs( pwc, p, MAX_BUFFER );
96 return pwc;
98 #else
99 char* WtoA( OLECHAR* p )
101 return debugstr_wn( p, MAX_BUFFER );
103 OLECHAR* AtoW( char* p )
105 return HEAP_strdupAtoW( GetProcessHeap(), 0, p );
107 #endif
110 int PASCAL WinMain (HANDLE inst, HANDLE prev, LPSTR cmdline, int show)
112 VARIANTARG va;
113 VARIANTARG vb;
114 VARIANTARG vc;
115 VARIANTARG vd;
116 VARIANTARG ve;
118 int theInt = 0;
119 int* pInt = &theInt;
120 VARIANT_BOOL b = 0;
121 VARIANT_BOOL* pBool = &b;
122 unsigned short uShort = 0;
123 unsigned short* pUShort = &uShort;
124 unsigned long uLong = 0;
125 unsigned long* pULong = &uLong;
126 CHAR theChar;
127 CHAR* pChar = &theChar;
128 BYTE byte;
129 BYTE* pByte = &byte;
130 short s = 0;
131 short* pShort = &s;
132 long Long = 0;
133 long* pLong = &Long;
134 float f = 0;
135 float* pFloat = &f;
136 double d = 0;
137 double* pDouble = &d;
139 unsigned short i = 0;
140 HRESULT res = 0;
141 BSTR bstr = NULL;
142 int olePtrIndex = 0;
143 int nOlePtrs = 120;
144 OLECHAR* pOleChar[120];
146 pOleChar[0] = AtoW( "-2" );
147 pOleChar[1] = AtoW( "-1" );
148 pOleChar[2] = AtoW( "-0.51" );
149 pOleChar[3] = AtoW( "-0.5" );
150 pOleChar[4] = AtoW( "-0.49" );
151 pOleChar[5] = AtoW( "-0.0" );
152 pOleChar[6] = AtoW( "0.0" );
153 pOleChar[7] = AtoW( "0.49" );
154 pOleChar[8] = AtoW( "0.5" );
155 pOleChar[9] = AtoW( "0.51" );
156 pOleChar[10] = AtoW( "1" );
157 pOleChar[11] = AtoW( "127" );
158 pOleChar[12] = AtoW( "128" );
159 pOleChar[13] = AtoW( "129" );
160 pOleChar[14] = AtoW( "255" );
161 pOleChar[15] = AtoW( "256" );
162 pOleChar[16] = AtoW( "257" );
163 pOleChar[17] = AtoW( "32767" );
164 pOleChar[18] = AtoW( "32768" );
165 pOleChar[19] = AtoW( "-32768" );
166 pOleChar[20] = AtoW( "-32769" );
167 pOleChar[21] = AtoW( "16777216" );
168 pOleChar[22] = AtoW( "16777217" );
169 pOleChar[23] = AtoW( "-16777216" );
170 pOleChar[24] = AtoW( "16777217" );
171 pOleChar[25] = AtoW( "2147483647" );
172 pOleChar[26] = AtoW( "2147483648" );
173 pOleChar[27] = AtoW( "-2147483647" );
174 pOleChar[28] = AtoW( "-2147483648" );
176 pOleChar[29] = AtoW( "" );
177 pOleChar[30] = AtoW( " " );
178 pOleChar[31] = AtoW( "1F" );
179 pOleChar[32] = AtoW( "1G" );
180 pOleChar[33] = AtoW( " 1 " );
181 pOleChar[34] = AtoW( " 1 2 " );
182 pOleChar[35] = AtoW( "1,2,3" );
183 pOleChar[36] = AtoW( "1 2 3" );
184 pOleChar[37] = AtoW( "1,2, 3" );
185 pOleChar[38] = AtoW( "1;2;3" );
186 pOleChar[39] = AtoW( "1.2.3" );
188 pOleChar[40] = AtoW( "0." );
189 pOleChar[41] = AtoW( ".0" );
190 pOleChar[42] = AtoW( "0.1E12" );
191 pOleChar[43] = AtoW( "2.4,E1" );
192 pOleChar[44] = AtoW( " +3.2,E1" );
193 pOleChar[45] = AtoW( "4E2.5" );
194 pOleChar[46] = AtoW( " 2E+2" );
195 pOleChar[47] = AtoW( "1 E+2" );
196 pOleChar[48] = AtoW( "." );
197 pOleChar[49] = AtoW( ".E2" );
198 pOleChar[50] = AtoW( "1000000000000000000000000000000000000000000000000000000000000000" );
199 pOleChar[51] = AtoW( "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001" );
200 pOleChar[52] = AtoW( "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001" );
201 pOleChar[53] = AtoW( "100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001" );
202 pOleChar[54] = AtoW( "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001" );
203 pOleChar[55] = AtoW( "65535" );
204 pOleChar[56] = AtoW( "65535.5" );
205 pOleChar[57] = AtoW( "65536" );
206 pOleChar[58] = AtoW( "4294967295" );
207 pOleChar[59] = AtoW( "4294967296" );
209 pOleChar[60] = AtoW( "1 January 99" );
210 pOleChar[61] = AtoW( "December 31, 2078" );
211 pOleChar[62] = AtoW( "January 1, 1900" );
212 pOleChar[63] = AtoW( "January 2 1900" );
213 pOleChar[64] = AtoW( "11.11.1999" );
214 pOleChar[65] = AtoW( "11/11/1999" );
215 pOleChar[66] = AtoW( " 11 / 11 / 1999" );
216 pOleChar[67] = AtoW( "11/11/1999:11:11:1134" );
217 pOleChar[68] = AtoW( "11/11/1999 11:11:11:1" );
218 pOleChar[69] = AtoW( "\t1999/\t11/21 11 :11:11am" );
220 pOleChar[70] = AtoW( "11/11/1999 11:11:11Am" );
221 pOleChar[71] = AtoW( "11/11/1999 11:11:11PM" );
222 pOleChar[72] = AtoW( "11/11/199911:11:11PM" );
223 pOleChar[73] = AtoW( "11/11/1999 0:0:11am" );
224 pOleChar[74] = AtoW( "11/11/1999 11,11:11am" );
225 pOleChar[75] = AtoW( "11/11/1999 11:11:11am" );
226 pOleChar[76] = AtoW( "11/11/1999 11/11:11am" );
227 pOleChar[77] = AtoW( "11/11/1999 11:11AM" );
228 pOleChar[78] = AtoW( "11/11/1999 1AM" );
229 pOleChar[79] = AtoW( "11/11/1999 0AM" );
231 pOleChar[80] = AtoW( "11/11/1999 11:11:11" );
232 pOleChar[81] = AtoW( "11/13/1999 0AM" );
233 pOleChar[82] = AtoW( "13/13/1999 0AM" );
234 pOleChar[83] = AtoW( "13/11/1999 0AM" );
235 pOleChar[84] = AtoW( "11/33/1999 0AM" );
236 pOleChar[85] = AtoW( "11/11/1999 AM" );
237 pOleChar[86] = AtoW( "1/1/0 0AM" );
238 pOleChar[87] = AtoW( "1/1/-1 0AM" );
239 pOleChar[88] = AtoW( "1999 January 3 9AM" );
240 pOleChar[89] = AtoW( "1 January 1999 11AM" );
242 pOleChar[90] = AtoW( "4AM 11/11/1999" );
243 pOleChar[91] = AtoW( "4:22 11/11/1999 AM" );
244 pOleChar[92] = AtoW( " 1 1 /11/1999" );
245 pOleChar[93] = AtoW( "11-11/1999 11:11:11.12AM" );
246 pOleChar[94] = AtoW( "1999 January 3, 9AM" );
247 pOleChar[95] = AtoW( "December, 31, 2078" );
248 pOleChar[96] = AtoW( "December, 31, 2078," );
249 pOleChar[97] = AtoW( "December, 31 2078" );
250 pOleChar[98] = AtoW( "11/99" );
251 pOleChar[99] = AtoW( "11-1999" );
253 pOleChar[100] = AtoW( "true" );
254 pOleChar[101] = AtoW( "True" );
255 pOleChar[102] = AtoW( "TRue" );
256 pOleChar[103] = AtoW( "TRUE" );
257 pOleChar[104] = AtoW( " TRUE" );
258 pOleChar[105] = AtoW( "FALSE " );
259 pOleChar[106] = AtoW( "False" );
260 pOleChar[107] = AtoW( "JustSomeText" );
261 pOleChar[108] = AtoW( "Just Some Text" );
262 pOleChar[109] = AtoW( "" );
264 pOleChar[110] = AtoW( "1.5" );
265 pOleChar[111] = AtoW( "2.5" );
266 pOleChar[112] = AtoW( "3.5" );
267 pOleChar[113] = AtoW( "4.5" );
268 pOleChar[114] = AtoW( "" );
269 pOleChar[115] = AtoW( "" );
270 pOleChar[116] = AtoW( "" );
271 pOleChar[117] = AtoW( "" );
272 pOleChar[118] = AtoW( "" );
273 pOleChar[119] = AtoW( "" );
276 /* Start testing the Low-Level API ( the coercions )
280 /* unsigned char from...
282 printf( "\n\n======== Testing VarUI1FromXXX ========\n");
284 /* res = VarUI1FromI2( 0, NULL );
286 printf( "VarUI1FromI2: passing in NULL as return val makes it crash, %X\n", (unsigned int) res );
288 res = VarUI1FromStr( NULL, 0, 0, pByte );
289 printf( "VarUI1FromStr: passing in NULL as param: %X\n", (unsigned int) res );
291 res = VarUI1FromI2( 0, pByte );
292 printf( "VarUI1FromI2: 0, %X, %X\n", *pByte, (unsigned int) res );
293 res = VarUI1FromI2( 69, pByte );
294 printf( "VarUI1FromI2: 69, %X, %X\n", *pByte, (unsigned int) res );
295 res = VarUI1FromI2( 70, pByte );
296 printf( "VarUI1FromI2: 70, %X, %X\n", *pByte, (unsigned int) res );
297 res = VarUI1FromI2( 128, pByte );
298 printf( "VarUI1FromI2: 128, %X, %X\n", *pByte, (unsigned int) res );
299 res = VarUI1FromI2( 255, pByte );
300 printf( "VarUI1FromI2: 255, %X, %X\n", *pByte, (unsigned int) res );
301 res = VarUI1FromI2( 256, pByte );
302 printf( "VarUI1FromI2: 256, %X, %X\n", *pByte, (unsigned int) res );
303 res = VarUI1FromI2( 257, pByte );
304 printf( "VarUI1FromI2: 257, %X, %X\n", *pByte, (unsigned int) res );
306 res = VarUI1FromR8( 0.0, pByte );
307 printf( "VarUI1FromR8: 0.0, %X, %X\n", *pByte, (unsigned int) res );
308 res = VarUI1FromR8( 69.33, pByte );
309 printf( "VarUI1FromR8: 69.33, %X, %X\n", *pByte, (unsigned int) res );
310 res = VarUI1FromR8( 69.66, pByte );
311 printf( "VarUI1FromR8: 69.66, %X, %X\n", *pByte, (unsigned int) res );
312 res = VarUI1FromR8( -69.33, pByte );
313 printf( "VarUI1FromR8: -69.33, %X, %X\n", *pByte, (unsigned int) res );
314 res = VarUI1FromR8( -69.66, pByte );
315 printf( "VarUI1FromR8: -69.66, %X, %X\n", *pByte, (unsigned int) res );
317 res = VarUI1FromR8( -0.5, pByte );
318 printf( "VarUI1FromR8: -0.5, %X, %X\n", *pByte, (unsigned int) res );
319 res = VarUI1FromR8( -0.51, pByte );
320 printf( "VarUI1FromR8: -0.51, %X, %X\n", *pByte, (unsigned int) res );
321 res = VarUI1FromR8( -0.49, pByte );
322 printf( "VarUI1FromR8: -0.49, %X, %X\n", *pByte, (unsigned int) res );
324 res = VarUI1FromR8( 0.5, pByte );
325 printf( "VarUI1FromR8: 0.5, %X, %X\n", *pByte, (unsigned int) res );
326 res = VarUI1FromR8( 0.51, pByte );
327 printf( "VarUI1FromR8: 0.51, %X, %X\n", *pByte, (unsigned int) res );
328 res = VarUI1FromR8( 0.49, pByte );
329 printf( "VarUI1FromR8: 0.49, %X, %X\n", *pByte, (unsigned int) res );
331 res = VarUI1FromDate( 0.0, pByte );
332 printf( "VarUI1FromDate: 0.0, %X, %X\n", *pByte, (unsigned int) res );
333 res = VarUI1FromDate( 69.33, pByte );
334 printf( "VarUI1FromDate: 69.33, %X, %X\n", *pByte, (unsigned int) res );
335 res = VarUI1FromDate( 69.66, pByte );
336 printf( "VarUI1FromDate: 69.66, %X, %X\n", *pByte, (unsigned int) res );
337 res = VarUI1FromDate( -69.33, pByte );
338 printf( "VarUI1FromDate: -69.33, %X, %X\n", *pByte, (unsigned int) res );
339 res = VarUI1FromDate( -69.66, pByte );
340 printf( "VarUI1FromDate: -69.66, %X, %X\n", *pByte, (unsigned int) res );
342 res = VarUI1FromBool( VARIANT_TRUE, pByte );
343 printf( "VarUI1FromBool: VARIANT_TRUE, %X, %X\n", *pByte, (unsigned int) res );
344 res = VarUI1FromBool( VARIANT_FALSE, pByte );
345 printf( "VarUI1FromBool: VARIANT_FALSE, %X, %X\n", *pByte, (unsigned int) res );
347 for( olePtrIndex = 0; olePtrIndex < nOlePtrs; olePtrIndex ++ )
349 res = VarUI1FromStr( pOleChar[olePtrIndex], 0, 0, pByte );
350 printf( "VarUI1FromStr: %s, %X, %X\n", WtoA(pOleChar[olePtrIndex]), *pByte, (unsigned int) res );
354 /* unsigned short from ...
356 printf( "\n\n======== Testing VarUI2FromXXX ========\n");
358 res = VarUI2FromI2( -1, &i );
359 printf( "VarUI2FromI2: -1, %d, %X\n", i, (unsigned int) res );
361 /* res = VarUI2FromI2( 0, NULL );
363 printf( "VarUI2FromI2: passing in NULL as return val makes it crash, %X\n", (unsigned int) res );
365 res = VarUI2FromStr( NULL, 0, 0, pUShort );
366 printf( "VarUI2FromStr: passing in NULL as param: %X\n", (unsigned int) res );
368 res = VarUI2FromI2( 0, pUShort );
369 printf( "VarUI2FromI2: 0, %u, %X\n", *pUShort, (unsigned int) res );
370 res = VarUI2FromI2( 69, pUShort );
371 printf( "VarUI2FromI2: 69, %u, %X\n", *pUShort, (unsigned int) res );
372 res = VarUI2FromI2( 70, pUShort );
373 printf( "VarUI2FromI2: 70, %u, %X\n", *pUShort, (unsigned int) res );
374 res = VarUI2FromI2( 128, pUShort );
375 printf( "VarUI2FromI2: 128, %u, %X\n", *pUShort, (unsigned int) res );
376 res = VarUI2FromI4( 65535, pUShort );
377 printf( "VarUI2FromI4: 65535, %u, %X\n", *pUShort, (unsigned int) res );
378 res = VarUI2FromI4( 65536, pUShort );
379 printf( "VarUI2FromI4: 65536, %u, %X\n", *pUShort, (unsigned int) res );
380 res = VarUI2FromI4( 65537, pUShort );
381 printf( "VarUI2FromI4: 65537, %u, %X\n", *pUShort, (unsigned int) res );
383 res = VarUI2FromR8( 0.0, pUShort );
384 printf( "VarUI2FromR8: 0.0, %u, %X\n", *pUShort, (unsigned int) res );
385 res = VarUI2FromR8( 69.33, pUShort );
386 printf( "VarUI2FromR8: 69.33, %u, %X\n", *pUShort, (unsigned int) res );
387 res = VarUI2FromR8( 69.66, pUShort );
388 printf( "VarUI2FromR8: 69.66, %u, %X\n", *pUShort, (unsigned int) res );
389 res = VarUI2FromR8( -69.33, pUShort );
390 printf( "VarUI2FromR8: -69.33, %u, %X\n", *pUShort, (unsigned int) res );
391 res = VarUI2FromR8( -69.66, pUShort );
392 printf( "VarUI2FromR8: -69.66, %u, %X\n", *pUShort, (unsigned int) res );
394 res = VarUI2FromR8( -0.5, pUShort );
395 printf( "VarUI2FromR8: -0.5, %u, %X\n", *pUShort, (unsigned int) res );
396 res = VarUI2FromR8( -0.51, pUShort );
397 printf( "VarUI2FromR8: -0.51, %u, %X\n", *pUShort, (unsigned int) res );
398 res = VarUI2FromR8( -0.49, pUShort );
399 printf( "VarUI2FromR8: -0.49, %u, %X\n", *pUShort, (unsigned int) res );
401 res = VarUI2FromR8( 0.5, pUShort );
402 printf( "VarUI2FromR8: 0.5, %u, %X\n", *pUShort, (unsigned int) res );
403 res = VarUI2FromR8( 0.51, pUShort );
404 printf( "VarUI2FromR8: 0.51, %u, %X\n", *pUShort, (unsigned int) res );
405 res = VarUI2FromR8( 0.49, pUShort );
406 printf( "VarUI2FromR8: 0.49, %u, %X\n", *pUShort, (unsigned int) res );
408 res = VarUI2FromDate( 0.0, pUShort );
409 printf( "VarUI2FromDate: 0.0, %u, %X\n", *pUShort, (unsigned int) res );
410 res = VarUI2FromDate( 69.33, pUShort );
411 printf( "VarUI2FromDate: 69.33, %u, %X\n", *pUShort, (unsigned int) res );
412 res = VarUI2FromDate( 69.66, pUShort );
413 printf( "VarUI2FromDate: 69.66, %u, %X\n", *pUShort, (unsigned int) res );
414 res = VarUI2FromDate( -69.33, pUShort );
415 printf( "VarUI2FromDate: -69.33, %u, %X\n", *pUShort, (unsigned int) res );
416 res = VarUI2FromDate( -69.66, pUShort );
417 printf( "VarUI2FromDate: -69.66, %u, %X\n", *pUShort, (unsigned int) res );
419 res = VarUI2FromBool( VARIANT_TRUE, pUShort );
420 printf( "VarUI2FromBool: VARIANT_TRUE, %u, %X\n", *pUShort, (unsigned int) res );
421 res = VarUI2FromBool( VARIANT_FALSE, pUShort );
422 printf( "VarUI2FromBool: VARIANT_FALSE, %u, %X\n", *pUShort, (unsigned int) res );
424 for( olePtrIndex = 0; olePtrIndex < nOlePtrs; olePtrIndex ++ )
426 res = VarUI2FromStr( pOleChar[olePtrIndex], 0, 0, pUShort );
427 printf( "VarUI2FromStr: %s, %u, %X\n", WtoA(pOleChar[olePtrIndex]), (int)*pUShort, (unsigned int) res );
430 /* unsigned long from ...
432 printf( "\n\n======== Testing VarUI4FromXXX ========\n");
434 /*res = VarUI4FromI2( 0, NULL );
436 printf( "VarUI4FromI2: passing in NULL as return val makes it crash, %X\n", (unsigned int) res );
438 res = VarUI4FromStr( NULL, 0, 0, pULong );
439 printf( "VarUI4FromStr: passing in NULL as param: %X\n", (unsigned int) res );
441 res = VarUI4FromI2( 0, pULong );
442 printf( "VarUI4FromI2: 0, %lu, %X\n", *pULong, (unsigned int) res );
443 res = VarUI4FromI2( 69, pULong );
444 printf( "VarUI4FromI2: 69, %lu, %X\n", *pULong, (unsigned int) res );
445 res = VarUI4FromI2( 70, pULong );
446 printf( "VarUI4FromI2: 70, %lu, %X\n", *pULong, (unsigned int) res );
447 res = VarUI4FromI2( 128, pULong );
448 printf( "VarUI4FromI2: 128, %lu, %X\n", *pULong, (unsigned int) res );
449 res = VarUI4FromI2( 255, pULong );
450 printf( "VarUI4FromI2: 255, %lu, %X\n", *pULong, (unsigned int) res );
451 res = VarUI4FromR8( 4294967295.0, pULong );
452 printf( "VarUI4FromR8: 4294967295, %lu, %X\n", *pULong, (unsigned int) res );
453 res = VarUI4FromR8( 4294967296.0, pULong );
454 printf( "VarUI4FromR8: 4294967296, %lu, %X\n", *pULong, (unsigned int) res );
456 res = VarUI4FromR8( 0.0, pULong );
457 printf( "VarUI4FromR8: 0.0, %lu, %X\n", *pULong, (unsigned int) res );
458 res = VarUI4FromR8( 69.33, pULong );
459 printf( "VarUI4FromR8: 69.33, %lu, %X\n", *pULong, (unsigned int) res );
460 res = VarUI4FromR8( 69.66, pULong );
461 printf( "VarUI4FromR8: 69.66, %lu, %X\n", *pULong, (unsigned int) res );
462 res = VarUI4FromR8( -69.33, pULong );
463 printf( "VarUI4FromR8: -69.33, %lu, %X\n", *pULong, (unsigned int) res );
464 res = VarUI4FromR8( -69.66, pULong );
465 printf( "VarUI4FromR8: -69.66, %lu, %X\n", *pULong, (unsigned int) res );
467 res = VarUI4FromR8( -0.5, pULong );
468 printf( "VarUI4FromR8: -0.5, %lu, %X\n", *pULong, (unsigned int) res );
469 res = VarUI4FromR8( -0.51, pULong );
470 printf( "VarUI4FromR8: -0.51, %lu, %X\n", *pULong, (unsigned int) res );
471 res = VarUI4FromR8( -0.49, pULong );
472 printf( "VarUI4FromR8: -0.49, %lu, %X\n", *pULong, (unsigned int) res );
474 res = VarUI4FromR8( 0.5, pULong );
475 printf( "VarUI4FromR8: 0.5, %lu, %X\n", *pULong, (unsigned int) res );
476 res = VarUI4FromR8( 0.51, pULong );
477 printf( "VarUI4FromR8: 0.51, %lu, %X\n", *pULong, (unsigned int) res );
478 res = VarUI4FromR8( 0.49, pULong );
479 printf( "VarUI4FromR8: 0.49, %lu, %X\n", *pULong, (unsigned int) res );
481 res = VarUI4FromDate( 0.0, pULong );
482 printf( "VarUI4FromDate: 0.0, %lu, %X\n", *pULong, (unsigned int) res );
483 res = VarUI4FromDate( 69.33, pULong );
484 printf( "VarUI4FromDate: 69.33, %lu, %X\n", *pULong, (unsigned int) res );
485 res = VarUI4FromDate( 69.66, pULong );
486 printf( "VarUI4FromDate: 69.66, %lu, %X\n", *pULong, (unsigned int) res );
487 res = VarUI4FromDate( -69.33, pULong );
488 printf( "VarUI4FromDate: -69.33, %lu, %X\n", *pULong, (unsigned int) res );
489 res = VarUI4FromDate( -69.66, pULong );
490 printf( "VarUI4FromDate: -69.66, %lu, %X\n", *pULong, (unsigned int) res );
492 res = VarUI4FromBool( VARIANT_TRUE, pULong );
493 printf( "VarUI4FromBool: VARIANT_TRUE, %lu, %X\n", *pULong, (unsigned int) res );
494 res = VarUI4FromBool( VARIANT_FALSE, pULong );
495 printf( "VarUI4FromBool: VARIANT_FALSE, %lu, %X\n", *pULong, (unsigned int) res );
497 for( olePtrIndex = 0; olePtrIndex < nOlePtrs; olePtrIndex ++ )
499 res = VarUI4FromStr( pOleChar[olePtrIndex], 0, 0, pULong );
500 printf( "VarUI4FromStr: %s, %lu, %X\n", WtoA(pOleChar[olePtrIndex]), *pULong, (unsigned int) res );
503 /* CHAR from ...
505 printf( "\n\n======== Testing VarI1FromXXX ========\n");
507 res = VarI1FromBool( VARIANT_TRUE, pByte );
508 printf( "VarI1FromBool: VARIANT_TRUE, %d, %X\n", *pByte, (unsigned int) res );
510 res = VarI1FromBool( VARIANT_TRUE, pChar );
511 printf( "VarI1FromBool: VARIANT_TRUE, %d, %X\n", *pChar, (unsigned int) res );
513 res = VarI1FromBool( VARIANT_FALSE, pChar );
514 printf( "VarI1FromBool: VARIANT_FALSE, %d, %X\n", *pChar, (unsigned int) res );
516 res = VarI1FromUI1( (unsigned char)32767, pChar );
517 printf( "VarI1FromUI1: 32767, %d, %X\n", *pChar, (unsigned int) res );
518 res = VarI1FromUI1( (unsigned char)65535, pChar );
519 printf( "VarI1FromUI1: 65535, %d, %X\n", *pChar, (unsigned int) res );
521 res = VarI1FromI4( 32767, pChar );
522 printf( "VarI1FromI4: 32767, %d, %X\n", *pChar, (unsigned int) res );
523 res = VarI1FromI4( 32768, pChar );
524 printf( "VarI1FromI4: 32768, %d, %X\n", *pChar, (unsigned int) res );
525 res = VarI1FromI4( -32768, pChar );
526 printf( "VarI1FromI4: -32768, %d, %X\n", *pChar, (unsigned int) res );
527 res = VarI1FromI4( -32769, pChar );
528 printf( "VarI1FromI4: -32769, %d, %X\n", *pChar, (unsigned int) res );
530 res = VarI1FromR8( 69.33, pChar );
531 printf( "VarI1FromR8: 69.33, %d, %X\n", *pChar, (unsigned int) res );
532 res = VarI1FromR8( 69.66, pChar );
533 printf( "VarI1FromR8: 69.66, %d, %X\n", *pChar, (unsigned int) res );
534 res = VarI1FromR8( -69.33, pChar );
535 printf( "VarI1FromR8: -69.33, %d, %X\n", *pChar, (unsigned int) res );
536 res = VarI1FromR8( -69.66, pChar );
537 printf( "VarI1FromR8: -69.66, %d, %X\n", *pChar, (unsigned int) res );
539 res = VarI1FromDate( -69.66, pChar );
540 printf( "VarI1FromDate: -69.66, %d, %X\n", *pChar, (unsigned int) res );
542 for( olePtrIndex = 0; olePtrIndex < nOlePtrs; olePtrIndex ++ )
544 res = VarI1FromStr( pOleChar[olePtrIndex], 0, 0, pChar );
545 printf( "VarI1FromStr: %s, %d, %X\n", WtoA(pOleChar[olePtrIndex]), *pChar, (unsigned int) res );
548 /* short from ...
550 printf( "\n\n======== Testing VarI2FromXXX ========\n");
552 res = VarI2FromUI2( 32767, pShort );
553 printf( "VarI2FromUI2: 32767, %d, %X\n", *pShort, (unsigned int) res );
554 res = VarI2FromUI2( 65535, pShort );
555 printf( "VarI2FromUI2: 65535, %d, %X\n", *pShort, (unsigned int) res );
557 res = VarI2FromI4( 32767, pShort );
558 printf( "VarI2FromI4: 32767, %d, %X\n", *pShort, (unsigned int) res );
559 res = VarI2FromI4( 32768, pShort );
560 printf( "VarI2FromI4: 32768, %d, %X\n", *pShort, (unsigned int) res );
561 res = VarI2FromI4( -32768, pShort );
562 printf( "VarI2FromI4: -32768, %d, %X\n", *pShort, (unsigned int) res );
563 res = VarI2FromI4( -32769, pShort );
564 printf( "VarI2FromI4: -32769, %d, %X\n", *pShort, (unsigned int) res );
566 res = VarI2FromR8( 69.33, pShort );
567 printf( "VarI2FromR8: 69.33, %d, %X\n", *pShort, (unsigned int) res );
568 res = VarI2FromR8( 69.66, pShort );
569 printf( "VarI2FromR8: 69.66, %d, %X\n", *pShort, (unsigned int) res );
570 res = VarI2FromR8( -69.33, pShort );
571 printf( "VarI2FromR8: -69.33, %d, %X\n", *pShort, (unsigned int) res );
572 res = VarI2FromR8( -69.66, pShort );
573 printf( "VarI2FromR8: -69.66, %d, %X\n", *pShort, (unsigned int) res );
575 res = VarI2FromDate( -69.66, pShort );
576 printf( "VarI2FromDate: -69.66, %d, %X\n", *pShort, (unsigned int) res );
578 for( olePtrIndex = 0; olePtrIndex < nOlePtrs; olePtrIndex ++ )
580 res = VarI2FromStr( pOleChar[olePtrIndex], 0, 0, pShort );
581 printf( "VarI2FromStr: %s, %d, %X\n", WtoA(pOleChar[olePtrIndex]), *pShort, (unsigned int) res );
584 /* long from ...
586 printf( "\n\n======== Testing VarI4FromXXX ========\n");
588 res = VarI4FromI2( 3, (long*)pInt );
589 printf( "VarIntFromI2: 3, %d, %X\n", *pInt, (unsigned int) res );
591 res = VarI4FromR8( 69.33, pLong );
592 printf( "VarI4FromR8: 69.33, %ld, %X\n", *pLong, (unsigned int) res );
593 res = VarI4FromR8( 69.66, pLong );
594 printf( "VarI4FromR8: 69.66, %ld, %X\n", *pLong, (unsigned int) res );
595 res = VarI4FromR8( -69.33, pLong );
596 printf( "VarI4FromR8: -69.33, %ld, %X\n", *pLong, (unsigned int) res );
597 res = VarI4FromR8( -69.66, pLong );
598 printf( "VarI4FromR8: -69.66, %ld, %X\n", *pLong, (unsigned int) res );
600 res = VarI4FromR8( 2147483647.0, pLong );
601 printf( "VarI4FromR8: 2147483647.0, %ld, %X\n", *pLong, (unsigned int) res );
602 res = VarI4FromR8( 2147483648.0, pLong );
603 printf( "VarI4FromR8: 2147483648.0, %ld, %X\n", *pLong, (unsigned int) res );
604 res = VarI4FromR8( -2147483647.0, pLong );
605 printf( "VarI4FromR8: -2147483647.0, %ld, %X\n", *pLong, (unsigned int) res );
606 res = VarI4FromR8( -2147483648.0, pLong );
607 printf( "VarI4FromR8: -2147483648.0, %ld, %X\n", *pLong, (unsigned int) res );
608 res = VarI4FromR8( -2147483649.0, pLong );
609 printf( "VarI4FromR8: -2147483649.0, %ld, %X\n", *pLong, (unsigned int) res );
611 res = VarI4FromDate( -2147483649.0, pLong );
612 printf( "VarI4FromDate: -2147483649.0, %ld, %X\n", *pLong, (unsigned int) res );
614 for( olePtrIndex = 0; olePtrIndex < nOlePtrs; olePtrIndex ++ )
616 res = VarI4FromStr( pOleChar[olePtrIndex], 0, 0, pLong );
617 printf( "VarI4FromStr: %s, %ld, %X\n", WtoA(pOleChar[olePtrIndex]), *pLong, (unsigned int) res );
620 /* float from ...
622 printf( "\n\n======== Testing VarR4FromXXX ========\n");
624 res = VarR4FromI4( 16777216, pFloat );
625 printf( "VarR4FromI4: 16777216, %f, %X\n", *pFloat, (unsigned int) res );
626 res = VarR4FromI4( 16777217, pFloat );
627 printf( "VarR4FromI4: 16777217, %f, %X\n", *pFloat, (unsigned int) res );
628 res = VarR4FromI4( -16777216, pFloat );
629 printf( "VarR4FromI4: -16777216, %f, %X\n", *pFloat, (unsigned int) res );
630 res = VarR4FromI4( -16777217, pFloat );
631 printf( "VarR4FromI4: -16777217, %f, %X\n", *pFloat, (unsigned int) res );
633 res = VarR4FromR8( 16777216.0, pFloat );
634 printf( "VarR4FromR8: 16777216.0, %f, %X\n", *pFloat, (unsigned int) res );
635 res = VarR4FromR8( 16777217.0, pFloat );
636 printf( "VarR4FromR8: 16777217.0, %f, %X\n", *pFloat, (unsigned int) res );
637 res = VarR4FromR8( -16777216.0, pFloat );
638 printf( "VarR4FromR8: -16777216.0, %f, %X\n", *pFloat, (unsigned int) res );
639 res = VarR4FromR8( -16777217.0, pFloat );
640 printf( "VarR4FromR8: -16777217.0, %f, %X\n", *pFloat, (unsigned int) res );
642 res = VarR4FromR8( 16777218e31, pFloat );
643 printf( "VarR4FromR8: 16777218e31, %f, %X\n", *pFloat, (unsigned int) res );
644 res = VarR4FromR8( 16777218e32, pFloat );
645 printf( "VarR4FromR8: 16777218e32, %f, %X\n", *pFloat, (unsigned int) res );
647 res = VarR4FromDate( 16777218e31, pFloat );
648 printf( "VarR4FromDate: 16777218e31, %f, %X\n", *pFloat, (unsigned int) res );
650 for( olePtrIndex = 0; olePtrIndex < nOlePtrs; olePtrIndex ++ )
652 res = VarR4FromStr( pOleChar[olePtrIndex], 0, 0, pFloat );
653 printf( "VarR4FromStr: %s, %f, %X\n", WtoA(pOleChar[olePtrIndex]), *pFloat, (unsigned int) res );
656 /* double from ...
658 printf( "\n\n======== Testing VarR8FromXXX ========\n");
660 res = VarR8FromDate( 900719925474099.0, pDouble );
661 printf( "VarR8FromDate: 900719925474099.0, %f, %X\n", *pDouble, (unsigned int) res );
663 for( olePtrIndex = 0; olePtrIndex < nOlePtrs; olePtrIndex ++ )
665 res = VarR8FromStr( pOleChar[olePtrIndex], 0, 0, pDouble );
666 printf( "VarR8FromStr: %s, %f, %X\n", WtoA(pOleChar[olePtrIndex]), *pDouble, (unsigned int) res );
669 /* date from ...
671 printf( "\n\n======== Testing VarDateFromXXX ========\n");
673 res = VarDateFromI4( 2958465, pDouble );
674 printf( "VarDateFromI4: 2958465, %f, %X\n", *pDouble, (unsigned int) res );
675 res = VarDateFromI4( 2958466, pDouble );
676 printf( "VarDateFromI4: 2958466, %f, %X\n", *pDouble, (unsigned int) res );
677 res = VarDateFromI4( -657434, pDouble );
678 printf( "VarDateFromI4: -657434, %f, %X\n", *pDouble, (unsigned int) res );
679 res = VarDateFromI4( -657435, pDouble );
680 printf( "VarDateFromI4: -657435, %f, %X\n", *pDouble, (unsigned int) res );
682 res = VarDateFromR8( 2958465.9999, pDouble );
683 printf( "VarDateFromR8: 2958465.9999, %f, %X\n", *pDouble, (unsigned int) res );
684 res = VarDateFromR8( 2958466, pDouble );
685 printf( "VarDateFromR8: 2958466, %f, %X\n", *pDouble, (unsigned int) res );
686 res = VarDateFromR8( -657434.9999, pDouble );
687 printf( "VarDateFromR8: -657434.9999, %f, %X\n", *pDouble, (unsigned int) res );
688 res = VarDateFromR8( -657435, pDouble );
689 printf( "VarDateFromR8: -657435, %f, %X\n", *pDouble, (unsigned int) res );
692 res = VarDateFromR8( 0.0, pDouble );
693 printf( "VarDateFromR8: 0.0, %f, %X\n", *pDouble, (unsigned int) res );
694 res = VarDateFromR8( 1.0, pDouble );
695 printf( "VarDateFromR8: 1.0, %f, %X\n", *pDouble, (unsigned int) res );
696 res = VarDateFromR8( 2.25, pDouble );
697 printf( "VarDateFromR8: 2.25, %f, %X\n", *pDouble, (unsigned int) res );
698 res = VarDateFromR8( -2.0, pDouble );
699 printf( "VarDateFromR8: -2.0, %f, %X\n", *pDouble, (unsigned int) res );
701 /* Need some parsing function in Linux to emulate this...
702 * Still in progess.
704 for( olePtrIndex = 0; olePtrIndex < nOlePtrs; olePtrIndex ++ )
706 res = VarDateFromStr( pOleChar[olePtrIndex], 0, 0, pDouble );
707 printf( "VarDateFromStr: %s, %f, %X\n", WtoA(pOleChar[olePtrIndex]), *pDouble, (unsigned int) res );
710 /* bool from ...
712 printf( "\n\n======== Testing VarBoolFromXXX ========\n");
714 res = VarBoolFromI4( 0, pBool );
715 printf( "VarBoolFromI4: 0, %d, %X\n", *pBool, (unsigned int) res );
716 res = VarBoolFromI4( 1, pBool );
717 printf( "VarBoolFromI4: 1, %d, %X\n", *pBool, (unsigned int) res );
718 res = VarBoolFromI4( -1, pBool );
719 printf( "VarBoolFromI4: -1, %d, %X\n", *pBool, (unsigned int) res );
720 res = VarBoolFromI4( 2, pBool );
721 printf( "VarBoolFromI4: 2, %d, %X\n", *pBool, (unsigned int) res );
723 res = VarBoolFromUI1( ' ', pBool );
724 printf( "VarBoolFromUI1: ' ', %d, %X\n", *pBool, (unsigned int) res );
725 res = VarBoolFromUI1( '\0', pBool );
726 printf( "VarBoolFromUI1: '\\0', %d, %X\n", *pBool, (unsigned int) res );
727 res = VarBoolFromUI1( 0x0000, pBool );
728 printf( "VarBoolFromUI1: 0x0000, %d, %X\n", *pBool, (unsigned int) res );
729 res = VarBoolFromUI1( (unsigned char)0xFFF, pBool );
730 printf( "VarBoolFromUI1: 0xFFF, %d, %X\n", *pBool, (unsigned int) res );
731 res = VarBoolFromUI1( (unsigned char)0xFFFF, pBool );
732 printf( "VarBoolFromUI1: 0xFFFF, %d, %X\n", *pBool, (unsigned int) res );
734 res = VarBoolFromR8( 0.0, pBool );
735 printf( "VarBoolFromR8: 0.0, %d, %X\n", *pBool, (unsigned int) res );
736 res = VarBoolFromR8( 1.1, pBool );
737 printf( "VarBoolFromR8: 1.1, %d, %X\n", *pBool, (unsigned int) res );
738 res = VarBoolFromR8( 0.5, pBool );
739 printf( "VarBoolFromR8: 0.5, %d, %X\n", *pBool, (unsigned int) res );
740 res = VarBoolFromR8( 0.49, pBool );
741 printf( "VarBoolFromR8: 0.49, %d, %X\n", *pBool, (unsigned int) res );
742 res = VarBoolFromR8( 0.51, pBool );
743 printf( "VarBoolFromR8: 0.51, %d, %X\n", *pBool, (unsigned int) res );
744 res = VarBoolFromR8( -0.5, pBool );
745 printf( "VarBoolFromR8: -0.5, %d, %X\n", *pBool, (unsigned int) res );
746 res = VarBoolFromR8( -0.49, pBool );
747 printf( "VarBoolFromR8: -0.49, %d, %X\n", *pBool, (unsigned int) res );
748 res = VarBoolFromR8( -0.51, pBool );
749 printf( "VarBoolFromR8: -0.51, %d, %X\n", *pBool, (unsigned int) res );
752 for( olePtrIndex = 0; olePtrIndex < nOlePtrs; olePtrIndex ++ )
754 res = VarBoolFromStr( pOleChar[olePtrIndex], 0, 0, pBool );
755 printf( "VarBoolFromStr: %s, %d, %X\n", WtoA(pOleChar[olePtrIndex]), *pBool, (unsigned int) res );
758 res = VarI1FromBool( VARIANT_TRUE, pByte );
759 printf( "VarI1FromBool: VARIANT_TRUE, %d, %X\n", *pByte, (unsigned int) res );
761 res = VarUI2FromI2( -1, &i );
762 printf( "VarUI2FromI2: -1, %d, %X\n", i, (unsigned int) res );
765 /* BSTR from ...
767 printf( "\n\n======== Testing VarBSTRFromXXX ========\n");
769 /* integers...
771 res = VarBstrFromI1( -100, 0, 0, &bstr );
772 printf( "VarBstrFromI1: -100, %s, %X\n", WtoA( bstr ), (unsigned int) res );
774 res = VarBstrFromUI1( 0x5A, 0, 0, &bstr );
775 printf( "VarBstrFromUI1: 0x5A, %s, %X\n", WtoA( bstr ), (unsigned int) res );
777 res = VarBstrFromI4( 2958465, 0, 0, &bstr );
778 printf( "VarBstrFromI4: 2958465, %s, %X\n", WtoA( bstr ), (unsigned int) res );
780 /* reals...
782 d=0;
783 for( i=0; i<20; i++ )
785 /* add an integer to the real number
787 d += ((i%9)+1) * pow( 10, i );
788 res = VarBstrFromR8( d, 0, 0, &bstr );
789 printf( "VarBstrFromR8: %f, %s, %X\n", d, WtoA( bstr ), (unsigned int) res );
790 res = VarBstrFromR8( -d, 0, 0, &bstr );
791 printf( "VarBstrFromR8: %f, %s, %X\n", -d, WtoA( bstr ), (unsigned int) res );
793 d=0;
794 for( i=0; i<20; i++ )
796 /* add a decimal to the real number
798 d += ((i%9)+1) * pow( 10, (i*-1) );
799 res = VarBstrFromR8( d, 0, 0, &bstr );
800 printf( "VarBstrFromR8: %f, %s, %X\n", d, WtoA( bstr ), (unsigned int) res );
801 res = VarBstrFromR8( d-1, 0, 0, &bstr );
802 printf( "VarBstrFromR8: %f, %s, %X\n", d-1, WtoA( bstr ), (unsigned int) res );
803 res = VarBstrFromR8( -d, 0, 0, &bstr );
804 printf( "VarBstrFromR8: %f, %s, %X\n", -d, WtoA( bstr ), (unsigned int) res );
807 d=0;
808 for( i=0; i<20; i++ )
810 /* add an integer to the real number
812 d += ((i%9)+1) * pow( 10, i );
813 /* add a decimal to the real number
815 d += ((i%9)+1) * pow( 10, (i*-1) );
816 res = VarBstrFromR8( d, 0, 0, &bstr );
817 printf( "VarBstrFromR8: %f, %s, %X\n", d, WtoA( bstr ), (unsigned int)res );
818 res = VarBstrFromR8( -d, 0, 0, &bstr );
819 printf( "VarBstrFromR8: %f, %s, %X\n", -d, WtoA( bstr ), (unsigned int) res );
824 d=0;
825 for( i=0; i<10; i++ )
827 /* add an integer to the real number
829 d += ((i%9)+1) * pow( 10, i );
830 res = VarBstrFromR4( (float)d, 0, 0, &bstr );
831 printf( "VarBstrFromR4: %f, %s, %X\n", d, WtoA( bstr ), (unsigned int) res );
832 res = VarBstrFromR4( (float)-d, 0, 0, &bstr );
833 printf( "VarBstrFromR4: %f, %s, %X\n", -d, WtoA( bstr ), (unsigned int) res );
835 d=0;
836 for( i=0; i<10; i++ )
838 /* add a decimal to the real number
840 d += ((i%9)+1) * pow( 10, (i*-1) );
841 res = VarBstrFromR4( (float)d, 0, 0, &bstr );
842 printf( "VarBstrFromR4: %f, %s, %X\n", d, WtoA( bstr ), (unsigned int) res );
843 res = VarBstrFromR4( (float)d-1, 0, 0, &bstr );
844 printf( "VarBstrFromR4: %f, %s, %X\n", d-1, WtoA( bstr ), (unsigned int) res );
845 res = VarBstrFromR4( (float)-d, 0, 0, &bstr );
846 printf( "VarBstrFromR4: %f, %s, %X\n", -d, WtoA( bstr ), (unsigned int) res );
849 d=0;
850 for( i=0; i<10; i++ )
852 /* add an integer to the real number
854 d += ((i%9)+1) * pow( 10, i );
855 /* add a decimal to the real number
857 d += ((i%9)+1) * pow( 10, (i*-1) );
858 res = VarBstrFromR4( (float)d, 0, 0, &bstr );
859 printf( "VarBstrFromR4: %f, %s, %X\n", d, WtoA( bstr ), (unsigned int) res );
860 res = VarBstrFromR4( (float)-d, 0, 0, &bstr );
861 printf( "VarBstrFromR4: %f, %s, %X\n", -d, WtoA( bstr ), (unsigned int) res );
864 res = VarBstrFromBool( 0x00, 0, 0, &bstr );
865 printf( "VarBstrFromBool: 0x00, %s, %X\n", WtoA( bstr ), (unsigned int) res );
866 res = VarBstrFromBool( 0xFF, 0, 0, &bstr );
867 printf( "VarBstrFromBool: 0xFF, %s, %X\n", WtoA( bstr ), (unsigned int) res );
869 res = VarBstrFromDate( 0.0, 0, 0, &bstr );
870 printf( "VarBstrFromDate: 0.0, %s, %X\n", WtoA( bstr ), (unsigned int) res );
871 res = VarBstrFromDate( 3.34, 0, 0, &bstr );
872 printf( "VarBstrFromDate: 3.34, %s, %X\n", WtoA( bstr ), (unsigned int) res );
873 res = VarBstrFromDate( 3339.34, 0, 0, &bstr );
874 printf( "VarBstrFromDate: 3339.34, %s, %X\n", WtoA( bstr ), (unsigned int) res );
875 res = VarBstrFromDate( 365.00, 0, 0, &bstr );
876 printf( "VarBstrFromDate: 365.00, %s, %X\n", WtoA( bstr ), (unsigned int) res );
877 res = VarBstrFromDate( 365.25, 0, 0, &bstr );
878 printf( "VarBstrFromDate: 365.25, %s, %X\n", WtoA( bstr ), (unsigned int) res );
879 res = VarBstrFromDate( 1461.0, 0, 0, &bstr );
880 printf( "VarBstrFromDate: 1461.00, %s, %X\n", WtoA( bstr ), (unsigned int) res );
881 res = VarBstrFromDate( 1461.5, 0, 0, &bstr );
882 printf( "VarBstrFromDate: 1461.5, %s, %X\n", WtoA( bstr ), (unsigned int) res );
885 res = VarBstrFromBool( 0x00, 0, 0, &bstr );
886 printf( "VarBstrFromBool: 0x00, %s, %X\n", WtoA(bstr), (unsigned int) res );
887 res = VarBstrFromBool( 0xFF, 0, 0, &bstr );
888 printf( "VarBstrFromBool: 0xFF, %s, %X\n", WtoA(bstr), (unsigned int) res );
890 res = VarBstrFromDate( 0.0, 0, 0, &bstr );
891 printf( "VarBstrFromDate: 0.0, %s, %X\n", WtoA(bstr), (unsigned int) res );
892 res = VarBstrFromDate( 3.34, 0, 0, &bstr );
893 printf( "VarBstrFromDate: 3.34, %s, %X\n", WtoA(bstr), (unsigned int) res );
895 /* Test variant API...
897 printf( "\n\n======== Testing Hi-Level Variant API ========\n");
899 bstr = SysAllocString( pOleChar[4] );
901 res = VariantClear( &va );
902 printf( "Result is: %x\n", (unsigned int)res );
904 VariantInit( &va );
905 VariantInit( &vb );
906 VariantInit( &vc );
907 VariantInit( &vd );
908 VariantInit( &ve );
910 va.vt = VT_BSTR;
911 va.u.bstrVal = bstr;
912 res = VariantClear( &va );
913 printf( "VariantClear: %x\n", (unsigned int)res );
914 printf( "VariantClear: %x\n", (unsigned int)res );
915 SysFreeString( bstr );
916 SysFreeString( bstr );
918 res = VariantCopy( &vb, &va );
919 printf( "VariantCopy: %x\n", (unsigned int)res );
920 res = VariantClear( &vb );
921 printf( "VariantClear: %x\n", (unsigned int)res );
922 res = VariantClear( &va );
923 printf( "VariantClear: %x\n", (unsigned int)res );
926 va.vt = VT_R8;
927 d = 4.123;
928 va.u.dblVal = d;
929 res = VariantCopy( &va, &va );
930 printf( "VariantCopy %f -> %f: %x\n", V_R8(&va), V_R8(&va), (unsigned int)res );
932 va.vt = VT_R8 | VT_BYREF;
933 d = 31.123;
934 va.u.pdblVal = &d;
935 res = VariantCopyInd( &va, &va );
936 printf( "VariantCopyInd %f: %x\n", V_R8(&va), (unsigned int)res );
938 va.vt = VT_R8;
939 d = 1.123;
940 va.u.dblVal = d;
941 res = VariantCopy( &vb, &va );
942 printf( "VariantCopy %f -> %f: %x\n", V_R8(&va), V_R8(&vb), (unsigned int)res );
944 va.vt = VT_R8 | VT_BYREF;
945 d = 123.123;
946 va.u.pdblVal = &d;
947 res = VariantCopy( &vb, &va );
948 printf( "VariantCopy %f -> %f: %x\n", *(V_R8REF(&va)), *(V_R8REF(&vb)), (unsigned int)res );
950 va.vt = VT_R8 | VT_BYREF;
951 d = 111.2;
952 va.u.pdblVal = &d;
953 res = VariantCopyInd( &vb, &va );
954 printf( "VariantCopyInd %f -> %f: %x\n", *(V_R8REF(&va)), V_R8(&vb), (unsigned int)res );
956 va.vt = VT_R8 | VT_BYREF;
957 d = 1211.123453;
958 va.u.pdblVal = &d;
959 res = VariantChangeTypeEx( &va, &va, 0, 0, VT_I2 );
960 printf( "VariantChangeTypeEx %d: %x\n", V_I2(&va), (unsigned int) res );
962 va.vt = VT_INT;
963 va.u.intVal = 4;
964 res = VariantChangeTypeEx(&vb, &va, 0, 0, VT_BSTR );
965 printf( "VariantChangeTypeEx %d -> %s: %x\n", V_INT(&va), WtoA(V_BSTR(&vb)), (unsigned int)res );
967 va.vt = VT_DATE;
968 va.u.date = 34465.332431;
969 res = VariantChangeTypeEx(&vb, &va, 0, 0, VT_BSTR );
970 printf( "VariantChangeTypeEx %f -> %s: %x\n", V_DATE(&va), WtoA(V_BSTR(&vb)), (unsigned int)res );
972 bstr = pOleChar[4];
973 va.vt = VT_BSTR;
974 va.u.bstrVal = bstr;
975 res = VariantChangeTypeEx(&vb, &va, 0, 0, VT_R8 );
976 printf( "VariantChangeTypeEx %s -> %f: %x\n", WtoA(V_BSTR(&va)), V_R8(&vb), (unsigned int)res );
979 vc.vt = VT_BSTR | VT_BYREF;
980 vc.u.pbstrVal = &bstr;
981 vb.vt = VT_VARIANT | VT_BYREF;
982 vb.u.pvarVal = &vc;
983 va.vt = VT_VARIANT | VT_BYREF;
984 va.u.pvarVal = &vb;
985 res = VariantCopyInd( &vd, &va );
986 printf( "VariantCopyInd: %x\n", (unsigned int)res );
988 /* test what happens when bad vartypes are passed in
990 printf( "-------------- Testing different VARTYPES ----------------\n" );
992 for( i=0; i<100; i++ )
994 /* Trying to use variants that are set to be BSTR but
995 * do not contain a valid pointer makes the program crash
996 * in Windows so we will skip those. We do not need them
997 * anyways to illustrate the behavior.
999 if( i == VT_BSTR )
1000 i = 77;
1002 va.vt = i;
1003 d = 4.123;
1004 va.u.dblVal = d;
1005 res = VariantCopyInd( &vb, &va );
1006 printf( "VariantCopyInd: %d -> %x\n", i, (unsigned int)res );
1008 va.vt = i | VT_BYREF;
1009 d = 4.123;
1010 va.u.pdblVal = &d;
1011 res = VariantCopyInd( &vb, &va );
1012 printf( "VariantCopyInd: %d -> %x\n", i, (unsigned int)res );
1014 va.vt = VT_R8;
1015 d = 4.123;
1016 va.u.dblVal = d;
1017 res = VariantChangeTypeEx( &vb, &va, 0, 0, i );
1018 printf( "VariantChangeTypeEx: %d -> %x\n", i, (unsigned int)res );
1020 va.vt = VT_R8;
1021 d = 4.123;
1022 va.u.dblVal = d;
1023 res = VariantChangeTypeEx( &vb, &va, 0, 0, i | VT_BYREF );
1024 printf( "VariantChangeTypeEx: VT_BYREF %d -> %x\n", i, (unsigned int)res );
1026 va.vt = 99;
1027 d = 4.123;
1028 va.u.dblVal = d;
1029 res = VariantClear( &va );
1030 printf( "VariantClear: %d -> %x\n", i, (unsigned int)res );
1034 res = VariantClear( &va );
1035 printf( "VariantClear: %x\n", (unsigned int)res );
1036 res = VariantClear( &vb );
1037 printf( "VariantClear: %x\n", (unsigned int)res );
1038 res = VariantClear( &vc );
1039 printf( "VariantClear: %x\n", (unsigned int)res );
1040 res = VariantClear( &vd );
1041 printf( "VariantClear: %x\n", (unsigned int)res );
1042 res = VariantClear( &ve );
1043 printf( "VariantClear: %x\n", (unsigned int)res );
1046 /* There is alot of memory leaks but this is simply a test program.
1049 return 0;