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.
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
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.
60 #include <debugtools.h>
61 extern LPWSTR
HEAP_strdupAtoW( HANDLE heap
, DWORD flags
, LPCSTR str
);
65 static const int MAX_BUFFER
= 1024;
69 char* WtoA( OLECHAR
* p
)
72 char* pc
= (char *)malloc( MAX_BUFFER
*sizeof(char) );
75 i
= wcstombs( pc
, p
, MAX_BUFFER
);
76 if( i
< MAX_BUFFER
-1 )
85 OLECHAR
* AtoW( char* p
)
88 OLECHAR
* pwc
= (OLECHAR
*)malloc( MAX_BUFFER
*sizeof(OLECHAR
) );
89 i
= mbstowcs( pwc
, p
, MAX_BUFFER
);
93 char* WtoA( OLECHAR
* p
)
95 return debugstr_wn( p
, MAX_BUFFER
);
97 OLECHAR
* AtoW( char* p
)
99 return HEAP_strdupAtoW( GetProcessHeap(), 0, p
);
104 int PASCAL
WinMain (HANDLE inst
, HANDLE prev
, LPSTR cmdline
, int show
)
115 VARIANT_BOOL
* pBool
= &b
;
116 unsigned short uShort
= 0;
117 unsigned short* pUShort
= &uShort
;
118 unsigned long uLong
= 0;
119 unsigned long* pULong
= &uLong
;
121 CHAR
* pChar
= &theChar
;
131 double* pDouble
= &d
;
133 unsigned short i
= 0;
138 OLECHAR
* pOleChar
[120];
140 pOleChar
[0] = AtoW( "-2" );
141 pOleChar
[1] = AtoW( "-1" );
142 pOleChar
[2] = AtoW( "-0.51" );
143 pOleChar
[3] = AtoW( "-0.5" );
144 pOleChar
[4] = AtoW( "-0.49" );
145 pOleChar
[5] = AtoW( "-0.0" );
146 pOleChar
[6] = AtoW( "0.0" );
147 pOleChar
[7] = AtoW( "0.49" );
148 pOleChar
[8] = AtoW( "0.5" );
149 pOleChar
[9] = AtoW( "0.51" );
150 pOleChar
[10] = AtoW( "1" );
151 pOleChar
[11] = AtoW( "127" );
152 pOleChar
[12] = AtoW( "128" );
153 pOleChar
[13] = AtoW( "129" );
154 pOleChar
[14] = AtoW( "255" );
155 pOleChar
[15] = AtoW( "256" );
156 pOleChar
[16] = AtoW( "257" );
157 pOleChar
[17] = AtoW( "32767" );
158 pOleChar
[18] = AtoW( "32768" );
159 pOleChar
[19] = AtoW( "-32768" );
160 pOleChar
[20] = AtoW( "-32769" );
161 pOleChar
[21] = AtoW( "16777216" );
162 pOleChar
[22] = AtoW( "16777217" );
163 pOleChar
[23] = AtoW( "-16777216" );
164 pOleChar
[24] = AtoW( "16777217" );
165 pOleChar
[25] = AtoW( "2147483647" );
166 pOleChar
[26] = AtoW( "2147483648" );
167 pOleChar
[27] = AtoW( "-2147483647" );
168 pOleChar
[28] = AtoW( "-2147483648" );
170 pOleChar
[29] = AtoW( "" );
171 pOleChar
[30] = AtoW( " " );
172 pOleChar
[31] = AtoW( "1F" );
173 pOleChar
[32] = AtoW( "1G" );
174 pOleChar
[33] = AtoW( " 1 " );
175 pOleChar
[34] = AtoW( " 1 2 " );
176 pOleChar
[35] = AtoW( "1,2,3" );
177 pOleChar
[36] = AtoW( "1 2 3" );
178 pOleChar
[37] = AtoW( "1,2, 3" );
179 pOleChar
[38] = AtoW( "1;2;3" );
180 pOleChar
[39] = AtoW( "1.2.3" );
182 pOleChar
[40] = AtoW( "0." );
183 pOleChar
[41] = AtoW( ".0" );
184 pOleChar
[42] = AtoW( "0.1E12" );
185 pOleChar
[43] = AtoW( "2.4,E1" );
186 pOleChar
[44] = AtoW( " +3.2,E1" );
187 pOleChar
[45] = AtoW( "4E2.5" );
188 pOleChar
[46] = AtoW( " 2E+2" );
189 pOleChar
[47] = AtoW( "1 E+2" );
190 pOleChar
[48] = AtoW( "." );
191 pOleChar
[49] = AtoW( ".E2" );
192 pOleChar
[50] = AtoW( "1000000000000000000000000000000000000000000000000000000000000000" );
193 pOleChar
[51] = AtoW( "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001" );
194 pOleChar
[52] = AtoW( "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001" );
195 pOleChar
[53] = AtoW( "100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001" );
196 pOleChar
[54] = AtoW( "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001" );
197 pOleChar
[55] = AtoW( "65535" );
198 pOleChar
[56] = AtoW( "65535.5" );
199 pOleChar
[57] = AtoW( "65536" );
200 pOleChar
[58] = AtoW( "4294967295" );
201 pOleChar
[59] = AtoW( "4294967296" );
203 pOleChar
[60] = AtoW( "1 January 99" );
204 pOleChar
[61] = AtoW( "December 31, 2078" );
205 pOleChar
[62] = AtoW( "January 1, 1900" );
206 pOleChar
[63] = AtoW( "January 2 1900" );
207 pOleChar
[64] = AtoW( "11.11.1999" );
208 pOleChar
[65] = AtoW( "11/11/1999" );
209 pOleChar
[66] = AtoW( " 11 / 11 / 1999" );
210 pOleChar
[67] = AtoW( "11/11/1999:11:11:1134" );
211 pOleChar
[68] = AtoW( "11/11/1999 11:11:11:1" );
212 pOleChar
[69] = AtoW( "\t1999/\t11/21 11 :11:11am" );
214 pOleChar
[70] = AtoW( "11/11/1999 11:11:11Am" );
215 pOleChar
[71] = AtoW( "11/11/1999 11:11:11PM" );
216 pOleChar
[72] = AtoW( "11/11/199911:11:11PM" );
217 pOleChar
[73] = AtoW( "11/11/1999 0:0:11am" );
218 pOleChar
[74] = AtoW( "11/11/1999 11,11:11am" );
219 pOleChar
[75] = AtoW( "11/11/1999 11:11:11am" );
220 pOleChar
[76] = AtoW( "11/11/1999 11/11:11am" );
221 pOleChar
[77] = AtoW( "11/11/1999 11:11AM" );
222 pOleChar
[78] = AtoW( "11/11/1999 1AM" );
223 pOleChar
[79] = AtoW( "11/11/1999 0AM" );
225 pOleChar
[80] = AtoW( "11/11/1999 11:11:11" );
226 pOleChar
[81] = AtoW( "11/13/1999 0AM" );
227 pOleChar
[82] = AtoW( "13/13/1999 0AM" );
228 pOleChar
[83] = AtoW( "13/11/1999 0AM" );
229 pOleChar
[84] = AtoW( "11/33/1999 0AM" );
230 pOleChar
[85] = AtoW( "11/11/1999 AM" );
231 pOleChar
[86] = AtoW( "1/1/0 0AM" );
232 pOleChar
[87] = AtoW( "1/1/-1 0AM" );
233 pOleChar
[88] = AtoW( "1999 January 3 9AM" );
234 pOleChar
[89] = AtoW( "1 January 1999 11AM" );
236 pOleChar
[90] = AtoW( "4AM 11/11/1999" );
237 pOleChar
[91] = AtoW( "4:22 11/11/1999 AM" );
238 pOleChar
[92] = AtoW( " 1 1 /11/1999" );
239 pOleChar
[93] = AtoW( "11-11/1999 11:11:11.12AM" );
240 pOleChar
[94] = AtoW( "1999 January 3, 9AM" );
241 pOleChar
[95] = AtoW( "December, 31, 2078" );
242 pOleChar
[96] = AtoW( "December, 31, 2078," );
243 pOleChar
[97] = AtoW( "December, 31 2078" );
244 pOleChar
[98] = AtoW( "11/99" );
245 pOleChar
[99] = AtoW( "11-1999" );
247 pOleChar
[100] = AtoW( "true" );
248 pOleChar
[101] = AtoW( "True" );
249 pOleChar
[102] = AtoW( "TRue" );
250 pOleChar
[103] = AtoW( "TRUE" );
251 pOleChar
[104] = AtoW( " TRUE" );
252 pOleChar
[105] = AtoW( "FALSE " );
253 pOleChar
[106] = AtoW( "False" );
254 pOleChar
[107] = AtoW( "JustSomeText" );
255 pOleChar
[108] = AtoW( "Just Some Text" );
256 pOleChar
[109] = AtoW( "" );
258 pOleChar
[110] = AtoW( "1.5" );
259 pOleChar
[111] = AtoW( "2.5" );
260 pOleChar
[112] = AtoW( "3.5" );
261 pOleChar
[113] = AtoW( "4.5" );
262 pOleChar
[114] = AtoW( "" );
263 pOleChar
[115] = AtoW( "" );
264 pOleChar
[116] = AtoW( "" );
265 pOleChar
[117] = AtoW( "" );
266 pOleChar
[118] = AtoW( "" );
267 pOleChar
[119] = AtoW( "" );
270 /* Start testing the Low-Level API ( the coercions )
274 /* unsigned char from...
276 printf( "\n\n======== Testing VarUI1FromXXX ========\n");
278 /* res = VarUI1FromI2( 0, NULL );
280 printf( "VarUI1FromI2: passing in NULL as return val makes it crash, %X\n", (unsigned int) res
);
282 res
= VarUI1FromStr( NULL
, 0, 0, pByte
);
283 printf( "VarUI1FromStr: passing in NULL as param: %X\n", (unsigned int) res
);
285 res
= VarUI1FromI2( 0, pByte
);
286 printf( "VarUI1FromI2: 0, %X, %X\n", *pByte
, (unsigned int) res
);
287 res
= VarUI1FromI2( 69, pByte
);
288 printf( "VarUI1FromI2: 69, %X, %X\n", *pByte
, (unsigned int) res
);
289 res
= VarUI1FromI2( 70, pByte
);
290 printf( "VarUI1FromI2: 70, %X, %X\n", *pByte
, (unsigned int) res
);
291 res
= VarUI1FromI2( 128, pByte
);
292 printf( "VarUI1FromI2: 128, %X, %X\n", *pByte
, (unsigned int) res
);
293 res
= VarUI1FromI2( 255, pByte
);
294 printf( "VarUI1FromI2: 255, %X, %X\n", *pByte
, (unsigned int) res
);
295 res
= VarUI1FromI2( 256, pByte
);
296 printf( "VarUI1FromI2: 256, %X, %X\n", *pByte
, (unsigned int) res
);
297 res
= VarUI1FromI2( 257, pByte
);
298 printf( "VarUI1FromI2: 257, %X, %X\n", *pByte
, (unsigned int) res
);
300 res
= VarUI1FromR8( 0.0, pByte
);
301 printf( "VarUI1FromR8: 0.0, %X, %X\n", *pByte
, (unsigned int) res
);
302 res
= VarUI1FromR8( 69.33, pByte
);
303 printf( "VarUI1FromR8: 69.33, %X, %X\n", *pByte
, (unsigned int) res
);
304 res
= VarUI1FromR8( 69.66, pByte
);
305 printf( "VarUI1FromR8: 69.66, %X, %X\n", *pByte
, (unsigned int) res
);
306 res
= VarUI1FromR8( -69.33, pByte
);
307 printf( "VarUI1FromR8: -69.33, %X, %X\n", *pByte
, (unsigned int) res
);
308 res
= VarUI1FromR8( -69.66, pByte
);
309 printf( "VarUI1FromR8: -69.66, %X, %X\n", *pByte
, (unsigned int) res
);
311 res
= VarUI1FromR8( -0.5, pByte
);
312 printf( "VarUI1FromR8: -0.5, %X, %X\n", *pByte
, (unsigned int) res
);
313 res
= VarUI1FromR8( -0.51, pByte
);
314 printf( "VarUI1FromR8: -0.51, %X, %X\n", *pByte
, (unsigned int) res
);
315 res
= VarUI1FromR8( -0.49, pByte
);
316 printf( "VarUI1FromR8: -0.49, %X, %X\n", *pByte
, (unsigned int) res
);
318 res
= VarUI1FromR8( 0.5, pByte
);
319 printf( "VarUI1FromR8: 0.5, %X, %X\n", *pByte
, (unsigned int) res
);
320 res
= VarUI1FromR8( 0.51, pByte
);
321 printf( "VarUI1FromR8: 0.51, %X, %X\n", *pByte
, (unsigned int) res
);
322 res
= VarUI1FromR8( 0.49, pByte
);
323 printf( "VarUI1FromR8: 0.49, %X, %X\n", *pByte
, (unsigned int) res
);
325 res
= VarUI1FromDate( 0.0, pByte
);
326 printf( "VarUI1FromDate: 0.0, %X, %X\n", *pByte
, (unsigned int) res
);
327 res
= VarUI1FromDate( 69.33, pByte
);
328 printf( "VarUI1FromDate: 69.33, %X, %X\n", *pByte
, (unsigned int) res
);
329 res
= VarUI1FromDate( 69.66, pByte
);
330 printf( "VarUI1FromDate: 69.66, %X, %X\n", *pByte
, (unsigned int) res
);
331 res
= VarUI1FromDate( -69.33, pByte
);
332 printf( "VarUI1FromDate: -69.33, %X, %X\n", *pByte
, (unsigned int) res
);
333 res
= VarUI1FromDate( -69.66, pByte
);
334 printf( "VarUI1FromDate: -69.66, %X, %X\n", *pByte
, (unsigned int) res
);
336 res
= VarUI1FromBool( VARIANT_TRUE
, pByte
);
337 printf( "VarUI1FromBool: VARIANT_TRUE, %X, %X\n", *pByte
, (unsigned int) res
);
338 res
= VarUI1FromBool( VARIANT_FALSE
, pByte
);
339 printf( "VarUI1FromBool: VARIANT_FALSE, %X, %X\n", *pByte
, (unsigned int) res
);
341 for( olePtrIndex
= 0; olePtrIndex
< nOlePtrs
; olePtrIndex
++ )
343 res
= VarUI1FromStr( pOleChar
[olePtrIndex
], 0, 0, pByte
);
344 printf( "VarUI1FromStr: %s, %X, %X\n", WtoA(pOleChar
[olePtrIndex
]), *pByte
, (unsigned int) res
);
348 /* unsigned short from ...
350 printf( "\n\n======== Testing VarUI2FromXXX ========\n");
352 res
= VarUI2FromI2( -1, &i
);
353 printf( "VarUI2FromI2: -1, %d, %X\n", i
, (unsigned int) res
);
355 /* res = VarUI2FromI2( 0, NULL );
357 printf( "VarUI2FromI2: passing in NULL as return val makes it crash, %X\n", (unsigned int) res
);
359 res
= VarUI2FromStr( NULL
, 0, 0, pUShort
);
360 printf( "VarUI2FromStr: passing in NULL as param: %X\n", (unsigned int) res
);
362 res
= VarUI2FromI2( 0, pUShort
);
363 printf( "VarUI2FromI2: 0, %u, %X\n", *pUShort
, (unsigned int) res
);
364 res
= VarUI2FromI2( 69, pUShort
);
365 printf( "VarUI2FromI2: 69, %u, %X\n", *pUShort
, (unsigned int) res
);
366 res
= VarUI2FromI2( 70, pUShort
);
367 printf( "VarUI2FromI2: 70, %u, %X\n", *pUShort
, (unsigned int) res
);
368 res
= VarUI2FromI2( 128, pUShort
);
369 printf( "VarUI2FromI2: 128, %u, %X\n", *pUShort
, (unsigned int) res
);
370 res
= VarUI2FromI4( 65535, pUShort
);
371 printf( "VarUI2FromI4: 65535, %u, %X\n", *pUShort
, (unsigned int) res
);
372 res
= VarUI2FromI4( 65536, pUShort
);
373 printf( "VarUI2FromI4: 65536, %u, %X\n", *pUShort
, (unsigned int) res
);
374 res
= VarUI2FromI4( 65537, pUShort
);
375 printf( "VarUI2FromI4: 65537, %u, %X\n", *pUShort
, (unsigned int) res
);
377 res
= VarUI2FromR8( 0.0, pUShort
);
378 printf( "VarUI2FromR8: 0.0, %u, %X\n", *pUShort
, (unsigned int) res
);
379 res
= VarUI2FromR8( 69.33, pUShort
);
380 printf( "VarUI2FromR8: 69.33, %u, %X\n", *pUShort
, (unsigned int) res
);
381 res
= VarUI2FromR8( 69.66, pUShort
);
382 printf( "VarUI2FromR8: 69.66, %u, %X\n", *pUShort
, (unsigned int) res
);
383 res
= VarUI2FromR8( -69.33, pUShort
);
384 printf( "VarUI2FromR8: -69.33, %u, %X\n", *pUShort
, (unsigned int) res
);
385 res
= VarUI2FromR8( -69.66, pUShort
);
386 printf( "VarUI2FromR8: -69.66, %u, %X\n", *pUShort
, (unsigned int) res
);
388 res
= VarUI2FromR8( -0.5, pUShort
);
389 printf( "VarUI2FromR8: -0.5, %u, %X\n", *pUShort
, (unsigned int) res
);
390 res
= VarUI2FromR8( -0.51, pUShort
);
391 printf( "VarUI2FromR8: -0.51, %u, %X\n", *pUShort
, (unsigned int) res
);
392 res
= VarUI2FromR8( -0.49, pUShort
);
393 printf( "VarUI2FromR8: -0.49, %u, %X\n", *pUShort
, (unsigned int) res
);
395 res
= VarUI2FromR8( 0.5, pUShort
);
396 printf( "VarUI2FromR8: 0.5, %u, %X\n", *pUShort
, (unsigned int) res
);
397 res
= VarUI2FromR8( 0.51, pUShort
);
398 printf( "VarUI2FromR8: 0.51, %u, %X\n", *pUShort
, (unsigned int) res
);
399 res
= VarUI2FromR8( 0.49, pUShort
);
400 printf( "VarUI2FromR8: 0.49, %u, %X\n", *pUShort
, (unsigned int) res
);
402 res
= VarUI2FromDate( 0.0, pUShort
);
403 printf( "VarUI2FromDate: 0.0, %u, %X\n", *pUShort
, (unsigned int) res
);
404 res
= VarUI2FromDate( 69.33, pUShort
);
405 printf( "VarUI2FromDate: 69.33, %u, %X\n", *pUShort
, (unsigned int) res
);
406 res
= VarUI2FromDate( 69.66, pUShort
);
407 printf( "VarUI2FromDate: 69.66, %u, %X\n", *pUShort
, (unsigned int) res
);
408 res
= VarUI2FromDate( -69.33, pUShort
);
409 printf( "VarUI2FromDate: -69.33, %u, %X\n", *pUShort
, (unsigned int) res
);
410 res
= VarUI2FromDate( -69.66, pUShort
);
411 printf( "VarUI2FromDate: -69.66, %u, %X\n", *pUShort
, (unsigned int) res
);
413 res
= VarUI2FromBool( VARIANT_TRUE
, pUShort
);
414 printf( "VarUI2FromBool: VARIANT_TRUE, %u, %X\n", *pUShort
, (unsigned int) res
);
415 res
= VarUI2FromBool( VARIANT_FALSE
, pUShort
);
416 printf( "VarUI2FromBool: VARIANT_FALSE, %u, %X\n", *pUShort
, (unsigned int) res
);
418 for( olePtrIndex
= 0; olePtrIndex
< nOlePtrs
; olePtrIndex
++ )
420 res
= VarUI2FromStr( pOleChar
[olePtrIndex
], 0, 0, pUShort
);
421 printf( "VarUI2FromStr: %s, %u, %X\n", WtoA(pOleChar
[olePtrIndex
]), (int)*pUShort
, (unsigned int) res
);
424 /* unsigned long from ...
426 printf( "\n\n======== Testing VarUI4FromXXX ========\n");
428 /*res = VarUI4FromI2( 0, NULL );
430 printf( "VarUI4FromI2: passing in NULL as return val makes it crash, %X\n", (unsigned int) res
);
432 res
= VarUI4FromStr( NULL
, 0, 0, pULong
);
433 printf( "VarUI4FromStr: passing in NULL as param: %X\n", (unsigned int) res
);
435 res
= VarUI4FromI2( 0, pULong
);
436 printf( "VarUI4FromI2: 0, %lu, %X\n", *pULong
, (unsigned int) res
);
437 res
= VarUI4FromI2( 69, pULong
);
438 printf( "VarUI4FromI2: 69, %lu, %X\n", *pULong
, (unsigned int) res
);
439 res
= VarUI4FromI2( 70, pULong
);
440 printf( "VarUI4FromI2: 70, %lu, %X\n", *pULong
, (unsigned int) res
);
441 res
= VarUI4FromI2( 128, pULong
);
442 printf( "VarUI4FromI2: 128, %lu, %X\n", *pULong
, (unsigned int) res
);
443 res
= VarUI4FromI2( 255, pULong
);
444 printf( "VarUI4FromI2: 255, %lu, %X\n", *pULong
, (unsigned int) res
);
445 res
= VarUI4FromR8( 4294967295.0, pULong
);
446 printf( "VarUI4FromR8: 4294967295, %lu, %X\n", *pULong
, (unsigned int) res
);
447 res
= VarUI4FromR8( 4294967296.0, pULong
);
448 printf( "VarUI4FromR8: 4294967296, %lu, %X\n", *pULong
, (unsigned int) res
);
450 res
= VarUI4FromR8( 0.0, pULong
);
451 printf( "VarUI4FromR8: 0.0, %lu, %X\n", *pULong
, (unsigned int) res
);
452 res
= VarUI4FromR8( 69.33, pULong
);
453 printf( "VarUI4FromR8: 69.33, %lu, %X\n", *pULong
, (unsigned int) res
);
454 res
= VarUI4FromR8( 69.66, pULong
);
455 printf( "VarUI4FromR8: 69.66, %lu, %X\n", *pULong
, (unsigned int) res
);
456 res
= VarUI4FromR8( -69.33, pULong
);
457 printf( "VarUI4FromR8: -69.33, %lu, %X\n", *pULong
, (unsigned int) res
);
458 res
= VarUI4FromR8( -69.66, pULong
);
459 printf( "VarUI4FromR8: -69.66, %lu, %X\n", *pULong
, (unsigned int) res
);
461 res
= VarUI4FromR8( -0.5, pULong
);
462 printf( "VarUI4FromR8: -0.5, %lu, %X\n", *pULong
, (unsigned int) res
);
463 res
= VarUI4FromR8( -0.51, pULong
);
464 printf( "VarUI4FromR8: -0.51, %lu, %X\n", *pULong
, (unsigned int) res
);
465 res
= VarUI4FromR8( -0.49, pULong
);
466 printf( "VarUI4FromR8: -0.49, %lu, %X\n", *pULong
, (unsigned int) res
);
468 res
= VarUI4FromR8( 0.5, pULong
);
469 printf( "VarUI4FromR8: 0.5, %lu, %X\n", *pULong
, (unsigned int) res
);
470 res
= VarUI4FromR8( 0.51, pULong
);
471 printf( "VarUI4FromR8: 0.51, %lu, %X\n", *pULong
, (unsigned int) res
);
472 res
= VarUI4FromR8( 0.49, pULong
);
473 printf( "VarUI4FromR8: 0.49, %lu, %X\n", *pULong
, (unsigned int) res
);
475 res
= VarUI4FromDate( 0.0, pULong
);
476 printf( "VarUI4FromDate: 0.0, %lu, %X\n", *pULong
, (unsigned int) res
);
477 res
= VarUI4FromDate( 69.33, pULong
);
478 printf( "VarUI4FromDate: 69.33, %lu, %X\n", *pULong
, (unsigned int) res
);
479 res
= VarUI4FromDate( 69.66, pULong
);
480 printf( "VarUI4FromDate: 69.66, %lu, %X\n", *pULong
, (unsigned int) res
);
481 res
= VarUI4FromDate( -69.33, pULong
);
482 printf( "VarUI4FromDate: -69.33, %lu, %X\n", *pULong
, (unsigned int) res
);
483 res
= VarUI4FromDate( -69.66, pULong
);
484 printf( "VarUI4FromDate: -69.66, %lu, %X\n", *pULong
, (unsigned int) res
);
486 res
= VarUI4FromBool( VARIANT_TRUE
, pULong
);
487 printf( "VarUI4FromBool: VARIANT_TRUE, %lu, %X\n", *pULong
, (unsigned int) res
);
488 res
= VarUI4FromBool( VARIANT_FALSE
, pULong
);
489 printf( "VarUI4FromBool: VARIANT_FALSE, %lu, %X\n", *pULong
, (unsigned int) res
);
491 for( olePtrIndex
= 0; olePtrIndex
< nOlePtrs
; olePtrIndex
++ )
493 res
= VarUI4FromStr( pOleChar
[olePtrIndex
], 0, 0, pULong
);
494 printf( "VarUI4FromStr: %s, %lu, %X\n", WtoA(pOleChar
[olePtrIndex
]), *pULong
, (unsigned int) res
);
499 printf( "\n\n======== Testing VarI1FromXXX ========\n");
501 res
= VarI1FromBool( VARIANT_TRUE
, pByte
);
502 printf( "VarI1FromBool: VARIANT_TRUE, %d, %X\n", *pByte
, (unsigned int) res
);
504 res
= VarI1FromBool( VARIANT_TRUE
, pChar
);
505 printf( "VarI1FromBool: VARIANT_TRUE, %d, %X\n", *pChar
, (unsigned int) res
);
507 res
= VarI1FromBool( VARIANT_FALSE
, pChar
);
508 printf( "VarI1FromBool: VARIANT_FALSE, %d, %X\n", *pChar
, (unsigned int) res
);
510 res
= VarI1FromUI1( (unsigned char)32767, pChar
);
511 printf( "VarI1FromUI1: 32767, %d, %X\n", *pChar
, (unsigned int) res
);
512 res
= VarI1FromUI1( (unsigned char)65535, pChar
);
513 printf( "VarI1FromUI1: 65535, %d, %X\n", *pChar
, (unsigned int) res
);
515 res
= VarI1FromI4( 32767, pChar
);
516 printf( "VarI1FromI4: 32767, %d, %X\n", *pChar
, (unsigned int) res
);
517 res
= VarI1FromI4( 32768, pChar
);
518 printf( "VarI1FromI4: 32768, %d, %X\n", *pChar
, (unsigned int) res
);
519 res
= VarI1FromI4( -32768, pChar
);
520 printf( "VarI1FromI4: -32768, %d, %X\n", *pChar
, (unsigned int) res
);
521 res
= VarI1FromI4( -32769, pChar
);
522 printf( "VarI1FromI4: -32769, %d, %X\n", *pChar
, (unsigned int) res
);
524 res
= VarI1FromR8( 69.33, pChar
);
525 printf( "VarI1FromR8: 69.33, %d, %X\n", *pChar
, (unsigned int) res
);
526 res
= VarI1FromR8( 69.66, pChar
);
527 printf( "VarI1FromR8: 69.66, %d, %X\n", *pChar
, (unsigned int) res
);
528 res
= VarI1FromR8( -69.33, pChar
);
529 printf( "VarI1FromR8: -69.33, %d, %X\n", *pChar
, (unsigned int) res
);
530 res
= VarI1FromR8( -69.66, pChar
);
531 printf( "VarI1FromR8: -69.66, %d, %X\n", *pChar
, (unsigned int) res
);
533 res
= VarI1FromDate( -69.66, pChar
);
534 printf( "VarI1FromDate: -69.66, %d, %X\n", *pChar
, (unsigned int) res
);
536 for( olePtrIndex
= 0; olePtrIndex
< nOlePtrs
; olePtrIndex
++ )
538 res
= VarI1FromStr( pOleChar
[olePtrIndex
], 0, 0, pChar
);
539 printf( "VarI1FromStr: %s, %d, %X\n", WtoA(pOleChar
[olePtrIndex
]), *pChar
, (unsigned int) res
);
544 printf( "\n\n======== Testing VarI2FromXXX ========\n");
546 res
= VarI2FromUI2( 32767, pShort
);
547 printf( "VarI2FromUI2: 32767, %d, %X\n", *pShort
, (unsigned int) res
);
548 res
= VarI2FromUI2( 65535, pShort
);
549 printf( "VarI2FromUI2: 65535, %d, %X\n", *pShort
, (unsigned int) res
);
551 res
= VarI2FromI4( 32767, pShort
);
552 printf( "VarI2FromI4: 32767, %d, %X\n", *pShort
, (unsigned int) res
);
553 res
= VarI2FromI4( 32768, pShort
);
554 printf( "VarI2FromI4: 32768, %d, %X\n", *pShort
, (unsigned int) res
);
555 res
= VarI2FromI4( -32768, pShort
);
556 printf( "VarI2FromI4: -32768, %d, %X\n", *pShort
, (unsigned int) res
);
557 res
= VarI2FromI4( -32769, pShort
);
558 printf( "VarI2FromI4: -32769, %d, %X\n", *pShort
, (unsigned int) res
);
560 res
= VarI2FromR8( 69.33, pShort
);
561 printf( "VarI2FromR8: 69.33, %d, %X\n", *pShort
, (unsigned int) res
);
562 res
= VarI2FromR8( 69.66, pShort
);
563 printf( "VarI2FromR8: 69.66, %d, %X\n", *pShort
, (unsigned int) res
);
564 res
= VarI2FromR8( -69.33, pShort
);
565 printf( "VarI2FromR8: -69.33, %d, %X\n", *pShort
, (unsigned int) res
);
566 res
= VarI2FromR8( -69.66, pShort
);
567 printf( "VarI2FromR8: -69.66, %d, %X\n", *pShort
, (unsigned int) res
);
569 res
= VarI2FromDate( -69.66, pShort
);
570 printf( "VarI2FromDate: -69.66, %d, %X\n", *pShort
, (unsigned int) res
);
572 for( olePtrIndex
= 0; olePtrIndex
< nOlePtrs
; olePtrIndex
++ )
574 res
= VarI2FromStr( pOleChar
[olePtrIndex
], 0, 0, pShort
);
575 printf( "VarI2FromStr: %s, %d, %X\n", WtoA(pOleChar
[olePtrIndex
]), *pShort
, (unsigned int) res
);
580 printf( "\n\n======== Testing VarI4FromXXX ========\n");
582 res
= VarI4FromI2( 3, (long*)pInt
);
583 printf( "VarIntFromI2: 3, %d, %X\n", *pInt
, (unsigned int) res
);
585 res
= VarI4FromR8( 69.33, pLong
);
586 printf( "VarI4FromR8: 69.33, %ld, %X\n", *pLong
, (unsigned int) res
);
587 res
= VarI4FromR8( 69.66, pLong
);
588 printf( "VarI4FromR8: 69.66, %ld, %X\n", *pLong
, (unsigned int) res
);
589 res
= VarI4FromR8( -69.33, pLong
);
590 printf( "VarI4FromR8: -69.33, %ld, %X\n", *pLong
, (unsigned int) res
);
591 res
= VarI4FromR8( -69.66, pLong
);
592 printf( "VarI4FromR8: -69.66, %ld, %X\n", *pLong
, (unsigned int) res
);
594 res
= VarI4FromR8( 2147483647.0, pLong
);
595 printf( "VarI4FromR8: 2147483647.0, %ld, %X\n", *pLong
, (unsigned int) res
);
596 res
= VarI4FromR8( 2147483648.0, pLong
);
597 printf( "VarI4FromR8: 2147483648.0, %ld, %X\n", *pLong
, (unsigned int) res
);
598 res
= VarI4FromR8( -2147483647.0, pLong
);
599 printf( "VarI4FromR8: -2147483647.0, %ld, %X\n", *pLong
, (unsigned int) res
);
600 res
= VarI4FromR8( -2147483648.0, pLong
);
601 printf( "VarI4FromR8: -2147483648.0, %ld, %X\n", *pLong
, (unsigned int) res
);
602 res
= VarI4FromR8( -2147483649.0, pLong
);
603 printf( "VarI4FromR8: -2147483649.0, %ld, %X\n", *pLong
, (unsigned int) res
);
605 res
= VarI4FromDate( -2147483649.0, pLong
);
606 printf( "VarI4FromDate: -2147483649.0, %ld, %X\n", *pLong
, (unsigned int) res
);
608 for( olePtrIndex
= 0; olePtrIndex
< nOlePtrs
; olePtrIndex
++ )
610 res
= VarI4FromStr( pOleChar
[olePtrIndex
], 0, 0, pLong
);
611 printf( "VarI4FromStr: %s, %ld, %X\n", WtoA(pOleChar
[olePtrIndex
]), *pLong
, (unsigned int) res
);
616 printf( "\n\n======== Testing VarR4FromXXX ========\n");
618 res
= VarR4FromI4( 16777216, pFloat
);
619 printf( "VarR4FromI4: 16777216, %f, %X\n", *pFloat
, (unsigned int) res
);
620 res
= VarR4FromI4( 16777217, pFloat
);
621 printf( "VarR4FromI4: 16777217, %f, %X\n", *pFloat
, (unsigned int) res
);
622 res
= VarR4FromI4( -16777216, pFloat
);
623 printf( "VarR4FromI4: -16777216, %f, %X\n", *pFloat
, (unsigned int) res
);
624 res
= VarR4FromI4( -16777217, pFloat
);
625 printf( "VarR4FromI4: -16777217, %f, %X\n", *pFloat
, (unsigned int) res
);
627 res
= VarR4FromR8( 16777216.0, pFloat
);
628 printf( "VarR4FromR8: 16777216.0, %f, %X\n", *pFloat
, (unsigned int) res
);
629 res
= VarR4FromR8( 16777217.0, pFloat
);
630 printf( "VarR4FromR8: 16777217.0, %f, %X\n", *pFloat
, (unsigned int) res
);
631 res
= VarR4FromR8( -16777216.0, pFloat
);
632 printf( "VarR4FromR8: -16777216.0, %f, %X\n", *pFloat
, (unsigned int) res
);
633 res
= VarR4FromR8( -16777217.0, pFloat
);
634 printf( "VarR4FromR8: -16777217.0, %f, %X\n", *pFloat
, (unsigned int) res
);
636 res
= VarR4FromR8( 16777218e31
, pFloat
);
637 printf( "VarR4FromR8: 16777218e31, %f, %X\n", *pFloat
, (unsigned int) res
);
638 res
= VarR4FromR8( 16777218e32
, pFloat
);
639 printf( "VarR4FromR8: 16777218e32, %f, %X\n", *pFloat
, (unsigned int) res
);
641 res
= VarR4FromDate( 16777218e31
, pFloat
);
642 printf( "VarR4FromDate: 16777218e31, %f, %X\n", *pFloat
, (unsigned int) res
);
644 for( olePtrIndex
= 0; olePtrIndex
< nOlePtrs
; olePtrIndex
++ )
646 res
= VarR4FromStr( pOleChar
[olePtrIndex
], 0, 0, pFloat
);
647 printf( "VarR4FromStr: %s, %f, %X\n", WtoA(pOleChar
[olePtrIndex
]), *pFloat
, (unsigned int) res
);
652 printf( "\n\n======== Testing VarR8FromXXX ========\n");
654 res
= VarR8FromDate( 900719925474099.0, pDouble
);
655 printf( "VarR8FromDate: 900719925474099.0, %f, %X\n", *pDouble
, (unsigned int) res
);
657 for( olePtrIndex
= 0; olePtrIndex
< nOlePtrs
; olePtrIndex
++ )
659 res
= VarR8FromStr( pOleChar
[olePtrIndex
], 0, 0, pDouble
);
660 printf( "VarR8FromStr: %s, %f, %X\n", WtoA(pOleChar
[olePtrIndex
]), *pDouble
, (unsigned int) res
);
665 printf( "\n\n======== Testing VarDateFromXXX ========\n");
667 res
= VarDateFromI4( 2958465, pDouble
);
668 printf( "VarDateFromI4: 2958465, %f, %X\n", *pDouble
, (unsigned int) res
);
669 res
= VarDateFromI4( 2958466, pDouble
);
670 printf( "VarDateFromI4: 2958466, %f, %X\n", *pDouble
, (unsigned int) res
);
671 res
= VarDateFromI4( -657434, pDouble
);
672 printf( "VarDateFromI4: -657434, %f, %X\n", *pDouble
, (unsigned int) res
);
673 res
= VarDateFromI4( -657435, pDouble
);
674 printf( "VarDateFromI4: -657435, %f, %X\n", *pDouble
, (unsigned int) res
);
676 res
= VarDateFromR8( 2958465.9999, pDouble
);
677 printf( "VarDateFromR8: 2958465.9999, %f, %X\n", *pDouble
, (unsigned int) res
);
678 res
= VarDateFromR8( 2958466, pDouble
);
679 printf( "VarDateFromR8: 2958466, %f, %X\n", *pDouble
, (unsigned int) res
);
680 res
= VarDateFromR8( -657434.9999, pDouble
);
681 printf( "VarDateFromR8: -657434.9999, %f, %X\n", *pDouble
, (unsigned int) res
);
682 res
= VarDateFromR8( -657435, pDouble
);
683 printf( "VarDateFromR8: -657435, %f, %X\n", *pDouble
, (unsigned int) res
);
686 res
= VarDateFromR8( 0.0, pDouble
);
687 printf( "VarDateFromR8: 0.0, %f, %X\n", *pDouble
, (unsigned int) res
);
688 res
= VarDateFromR8( 1.0, pDouble
);
689 printf( "VarDateFromR8: 1.0, %f, %X\n", *pDouble
, (unsigned int) res
);
690 res
= VarDateFromR8( 2.25, pDouble
);
691 printf( "VarDateFromR8: 2.25, %f, %X\n", *pDouble
, (unsigned int) res
);
692 res
= VarDateFromR8( -2.0, pDouble
);
693 printf( "VarDateFromR8: -2.0, %f, %X\n", *pDouble
, (unsigned int) res
);
695 /* Need some parsing function in Linux to emulate this...
698 for( olePtrIndex
= 0; olePtrIndex
< nOlePtrs
; olePtrIndex
++ )
700 res
= VarDateFromStr( pOleChar
[olePtrIndex
], 0, 0, pDouble
);
701 printf( "VarDateFromStr: %s, %f, %X\n", WtoA(pOleChar
[olePtrIndex
]), *pDouble
, (unsigned int) res
);
706 printf( "\n\n======== Testing VarBoolFromXXX ========\n");
708 res
= VarBoolFromI4( 0, pBool
);
709 printf( "VarBoolFromI4: 0, %d, %X\n", *pBool
, (unsigned int) res
);
710 res
= VarBoolFromI4( 1, pBool
);
711 printf( "VarBoolFromI4: 1, %d, %X\n", *pBool
, (unsigned int) res
);
712 res
= VarBoolFromI4( -1, pBool
);
713 printf( "VarBoolFromI4: -1, %d, %X\n", *pBool
, (unsigned int) res
);
714 res
= VarBoolFromI4( 2, pBool
);
715 printf( "VarBoolFromI4: 2, %d, %X\n", *pBool
, (unsigned int) res
);
717 res
= VarBoolFromUI1( ' ', pBool
);
718 printf( "VarBoolFromUI1: ' ', %d, %X\n", *pBool
, (unsigned int) res
);
719 res
= VarBoolFromUI1( '\0', pBool
);
720 printf( "VarBoolFromUI1: '\\0', %d, %X\n", *pBool
, (unsigned int) res
);
721 res
= VarBoolFromUI1( 0x0000, pBool
);
722 printf( "VarBoolFromUI1: 0x0000, %d, %X\n", *pBool
, (unsigned int) res
);
723 res
= VarBoolFromUI1( (unsigned char)0xFFF, pBool
);
724 printf( "VarBoolFromUI1: 0xFFF, %d, %X\n", *pBool
, (unsigned int) res
);
725 res
= VarBoolFromUI1( (unsigned char)0xFFFF, pBool
);
726 printf( "VarBoolFromUI1: 0xFFFF, %d, %X\n", *pBool
, (unsigned int) res
);
728 res
= VarBoolFromR8( 0.0, pBool
);
729 printf( "VarBoolFromR8: 0.0, %d, %X\n", *pBool
, (unsigned int) res
);
730 res
= VarBoolFromR8( 1.1, pBool
);
731 printf( "VarBoolFromR8: 1.1, %d, %X\n", *pBool
, (unsigned int) res
);
732 res
= VarBoolFromR8( 0.5, pBool
);
733 printf( "VarBoolFromR8: 0.5, %d, %X\n", *pBool
, (unsigned int) res
);
734 res
= VarBoolFromR8( 0.49, pBool
);
735 printf( "VarBoolFromR8: 0.49, %d, %X\n", *pBool
, (unsigned int) res
);
736 res
= VarBoolFromR8( 0.51, pBool
);
737 printf( "VarBoolFromR8: 0.51, %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
);
746 for( olePtrIndex
= 0; olePtrIndex
< nOlePtrs
; olePtrIndex
++ )
748 res
= VarBoolFromStr( pOleChar
[olePtrIndex
], 0, 0, pBool
);
749 printf( "VarBoolFromStr: %s, %d, %X\n", WtoA(pOleChar
[olePtrIndex
]), *pBool
, (unsigned int) res
);
752 res
= VarI1FromBool( VARIANT_TRUE
, pByte
);
753 printf( "VarI1FromBool: VARIANT_TRUE, %d, %X\n", *pByte
, (unsigned int) res
);
755 res
= VarUI2FromI2( -1, &i
);
756 printf( "VarUI2FromI2: -1, %d, %X\n", i
, (unsigned int) res
);
761 printf( "\n\n======== Testing VarBSTRFromXXX ========\n");
765 res
= VarBstrFromI1( -100, 0, 0, &bstr
);
766 printf( "VarBstrFromI1: -100, %s, %X\n", WtoA( bstr
), (unsigned int) res
);
768 res
= VarBstrFromUI1( 0x5A, 0, 0, &bstr
);
769 printf( "VarBstrFromUI1: 0x5A, %s, %X\n", WtoA( bstr
), (unsigned int) res
);
771 res
= VarBstrFromI4( 2958465, 0, 0, &bstr
);
772 printf( "VarBstrFromI4: 2958465, %s, %X\n", WtoA( bstr
), (unsigned int) res
);
777 for( i
=0; i
<20; i
++ )
779 /* add an integer to the real number
781 d
+= ((i
%9)+1) * pow( 10, i
);
782 res
= VarBstrFromR8( d
, 0, 0, &bstr
);
783 printf( "VarBstrFromR8: %f, %s, %X\n", d
, WtoA( bstr
), (unsigned int) res
);
784 res
= VarBstrFromR8( -d
, 0, 0, &bstr
);
785 printf( "VarBstrFromR8: %f, %s, %X\n", -d
, WtoA( bstr
), (unsigned int) res
);
788 for( i
=0; i
<20; i
++ )
790 /* add a decimal to the real number
792 d
+= ((i
%9)+1) * pow( 10, (i
*-1) );
793 res
= VarBstrFromR8( d
, 0, 0, &bstr
);
794 printf( "VarBstrFromR8: %f, %s, %X\n", d
, WtoA( bstr
), (unsigned int) res
);
795 res
= VarBstrFromR8( d
-1, 0, 0, &bstr
);
796 printf( "VarBstrFromR8: %f, %s, %X\n", d
-1, WtoA( bstr
), (unsigned int) res
);
797 res
= VarBstrFromR8( -d
, 0, 0, &bstr
);
798 printf( "VarBstrFromR8: %f, %s, %X\n", -d
, WtoA( bstr
), (unsigned int) res
);
802 for( i
=0; i
<20; i
++ )
804 /* add an integer to the real number
806 d
+= ((i
%9)+1) * pow( 10, i
);
807 /* add a decimal to the real number
809 d
+= ((i
%9)+1) * pow( 10, (i
*-1) );
810 res
= VarBstrFromR8( d
, 0, 0, &bstr
);
811 printf( "VarBstrFromR8: %f, %s, %X\n", d
, WtoA( bstr
), (unsigned int)res
);
812 res
= VarBstrFromR8( -d
, 0, 0, &bstr
);
813 printf( "VarBstrFromR8: %f, %s, %X\n", -d
, WtoA( bstr
), (unsigned int) res
);
819 for( i
=0; i
<10; i
++ )
821 /* add an integer to the real number
823 d
+= ((i
%9)+1) * pow( 10, i
);
824 res
= VarBstrFromR4( (float)d
, 0, 0, &bstr
);
825 printf( "VarBstrFromR4: %f, %s, %X\n", d
, WtoA( bstr
), (unsigned int) res
);
826 res
= VarBstrFromR4( (float)-d
, 0, 0, &bstr
);
827 printf( "VarBstrFromR4: %f, %s, %X\n", -d
, WtoA( bstr
), (unsigned int) res
);
830 for( i
=0; i
<10; i
++ )
832 /* add a decimal to the real number
834 d
+= ((i
%9)+1) * pow( 10, (i
*-1) );
835 res
= VarBstrFromR4( (float)d
, 0, 0, &bstr
);
836 printf( "VarBstrFromR4: %f, %s, %X\n", d
, WtoA( bstr
), (unsigned int) res
);
837 res
= VarBstrFromR4( (float)d
-1, 0, 0, &bstr
);
838 printf( "VarBstrFromR4: %f, %s, %X\n", d
-1, WtoA( bstr
), (unsigned int) res
);
839 res
= VarBstrFromR4( (float)-d
, 0, 0, &bstr
);
840 printf( "VarBstrFromR4: %f, %s, %X\n", -d
, WtoA( bstr
), (unsigned int) res
);
844 for( i
=0; i
<10; i
++ )
846 /* add an integer to the real number
848 d
+= ((i
%9)+1) * pow( 10, i
);
849 /* add a decimal to the real number
851 d
+= ((i
%9)+1) * pow( 10, (i
*-1) );
852 res
= VarBstrFromR4( (float)d
, 0, 0, &bstr
);
853 printf( "VarBstrFromR4: %f, %s, %X\n", d
, WtoA( bstr
), (unsigned int) res
);
854 res
= VarBstrFromR4( (float)-d
, 0, 0, &bstr
);
855 printf( "VarBstrFromR4: %f, %s, %X\n", -d
, WtoA( bstr
), (unsigned int) res
);
858 res
= VarBstrFromBool( 0x00, 0, 0, &bstr
);
859 printf( "VarBstrFromBool: 0x00, %s, %X\n", WtoA( bstr
), (unsigned int) res
);
860 res
= VarBstrFromBool( 0xFF, 0, 0, &bstr
);
861 printf( "VarBstrFromBool: 0xFF, %s, %X\n", WtoA( bstr
), (unsigned int) res
);
863 res
= VarBstrFromDate( 0.0, 0, 0, &bstr
);
864 printf( "VarBstrFromDate: 0.0, %s, %X\n", WtoA( bstr
), (unsigned int) res
);
865 res
= VarBstrFromDate( 3.34, 0, 0, &bstr
);
866 printf( "VarBstrFromDate: 3.34, %s, %X\n", WtoA( bstr
), (unsigned int) res
);
867 res
= VarBstrFromDate( 3339.34, 0, 0, &bstr
);
868 printf( "VarBstrFromDate: 3339.34, %s, %X\n", WtoA( bstr
), (unsigned int) res
);
869 res
= VarBstrFromDate( 365.00, 0, 0, &bstr
);
870 printf( "VarBstrFromDate: 365.00, %s, %X\n", WtoA( bstr
), (unsigned int) res
);
871 res
= VarBstrFromDate( 365.25, 0, 0, &bstr
);
872 printf( "VarBstrFromDate: 365.25, %s, %X\n", WtoA( bstr
), (unsigned int) res
);
873 res
= VarBstrFromDate( 1461.0, 0, 0, &bstr
);
874 printf( "VarBstrFromDate: 1461.00, %s, %X\n", WtoA( bstr
), (unsigned int) res
);
875 res
= VarBstrFromDate( 1461.5, 0, 0, &bstr
);
876 printf( "VarBstrFromDate: 1461.5, %s, %X\n", WtoA( bstr
), (unsigned int) res
);
879 res
= VarBstrFromBool( 0x00, 0, 0, &bstr
);
880 printf( "VarBstrFromBool: 0x00, %s, %X\n", WtoA(bstr
), (unsigned int) res
);
881 res
= VarBstrFromBool( 0xFF, 0, 0, &bstr
);
882 printf( "VarBstrFromBool: 0xFF, %s, %X\n", WtoA(bstr
), (unsigned int) res
);
884 res
= VarBstrFromDate( 0.0, 0, 0, &bstr
);
885 printf( "VarBstrFromDate: 0.0, %s, %X\n", WtoA(bstr
), (unsigned int) res
);
886 res
= VarBstrFromDate( 3.34, 0, 0, &bstr
);
887 printf( "VarBstrFromDate: 3.34, %s, %X\n", WtoA(bstr
), (unsigned int) res
);
889 /* Test variant API...
891 printf( "\n\n======== Testing Hi-Level Variant API ========\n");
893 bstr
= SysAllocString( pOleChar
[4] );
895 res
= VariantClear( &va
);
896 printf( "Result is: %x\n", (unsigned int)res
);
906 res
= VariantClear( &va
);
907 printf( "VariantClear: %x\n", (unsigned int)res
);
908 printf( "VariantClear: %x\n", (unsigned int)res
);
909 SysFreeString( bstr
);
910 SysFreeString( bstr
);
912 res
= VariantCopy( &vb
, &va
);
913 printf( "VariantCopy: %x\n", (unsigned int)res
);
914 res
= VariantClear( &vb
);
915 printf( "VariantClear: %x\n", (unsigned int)res
);
916 res
= VariantClear( &va
);
917 printf( "VariantClear: %x\n", (unsigned int)res
);
923 res
= VariantCopy( &va
, &va
);
924 printf( "VariantCopy %f -> %f: %x\n", V_R8(&va
), V_R8(&va
), (unsigned int)res
);
926 va
.vt
= VT_R8
| VT_BYREF
;
929 res
= VariantCopyInd( &va
, &va
);
930 printf( "VariantCopyInd %f: %x\n", V_R8(&va
), (unsigned int)res
);
935 res
= VariantCopy( &vb
, &va
);
936 printf( "VariantCopy %f -> %f: %x\n", V_R8(&va
), V_R8(&vb
), (unsigned int)res
);
938 va
.vt
= VT_R8
| VT_BYREF
;
941 res
= VariantCopy( &vb
, &va
);
942 printf( "VariantCopy %f -> %f: %x\n", *(V_R8REF(&va
)), *(V_R8REF(&vb
)), (unsigned int)res
);
944 va
.vt
= VT_R8
| VT_BYREF
;
947 res
= VariantCopyInd( &vb
, &va
);
948 printf( "VariantCopyInd %f -> %f: %x\n", *(V_R8REF(&va
)), V_R8(&vb
), (unsigned int)res
);
950 va
.vt
= VT_R8
| VT_BYREF
;
953 res
= VariantChangeTypeEx( &va
, &va
, 0, 0, VT_I2
);
954 printf( "VariantChangeTypeEx %d: %x\n", V_I2(&va
), (unsigned int) res
);
958 res
= VariantChangeTypeEx(&vb
, &va
, 0, 0, VT_BSTR
);
959 printf( "VariantChangeTypeEx %d -> %s: %x\n", V_INT(&va
), WtoA(V_BSTR(&vb
)), (unsigned int)res
);
962 va
.u
.date
= 34465.332431;
963 res
= VariantChangeTypeEx(&vb
, &va
, 0, 0, VT_BSTR
);
964 printf( "VariantChangeTypeEx %f -> %s: %x\n", V_DATE(&va
), WtoA(V_BSTR(&vb
)), (unsigned int)res
);
969 res
= VariantChangeTypeEx(&vb
, &va
, 0, 0, VT_R8
);
970 printf( "VariantChangeTypeEx %s -> %f: %x\n", WtoA(V_BSTR(&va
)), V_R8(&vb
), (unsigned int)res
);
973 vc
.vt
= VT_BSTR
| VT_BYREF
;
974 vc
.u
.pbstrVal
= &bstr
;
975 vb
.vt
= VT_VARIANT
| VT_BYREF
;
977 va
.vt
= VT_VARIANT
| VT_BYREF
;
979 res
= VariantCopyInd( &vd
, &va
);
980 printf( "VariantCopyInd: %x\n", (unsigned int)res
);
982 /* test what happens when bad vartypes are passed in
984 printf( "-------------- Testing different VARTYPES ----------------\n" );
986 for( i
=0; i
<100; i
++ )
988 /* Trying to use variants that are set to be BSTR but
989 * do not contain a valid pointer makes the program crash
990 * in Windows so we will skip those. We do not need them
991 * anyways to illustrate the behavior.
999 res
= VariantCopyInd( &vb
, &va
);
1000 printf( "VariantCopyInd: %d -> %x\n", i
, (unsigned int)res
);
1002 va
.vt
= i
| VT_BYREF
;
1005 res
= VariantCopyInd( &vb
, &va
);
1006 printf( "VariantCopyInd: %d -> %x\n", i
, (unsigned int)res
);
1011 res
= VariantChangeTypeEx( &vb
, &va
, 0, 0, i
);
1012 printf( "VariantChangeTypeEx: %d -> %x\n", i
, (unsigned int)res
);
1017 res
= VariantChangeTypeEx( &vb
, &va
, 0, 0, i
| VT_BYREF
);
1018 printf( "VariantChangeTypeEx: VT_BYREF %d -> %x\n", i
, (unsigned int)res
);
1023 res
= VariantClear( &va
);
1024 printf( "VariantClear: %d -> %x\n", i
, (unsigned int)res
);
1028 res
= VariantClear( &va
);
1029 printf( "VariantClear: %x\n", (unsigned int)res
);
1030 res
= VariantClear( &vb
);
1031 printf( "VariantClear: %x\n", (unsigned int)res
);
1032 res
= VariantClear( &vc
);
1033 printf( "VariantClear: %x\n", (unsigned int)res
);
1034 res
= VariantClear( &vd
);
1035 printf( "VariantClear: %x\n", (unsigned int)res
);
1036 res
= VariantClear( &ve
);
1037 printf( "VariantClear: %x\n", (unsigned int)res
);
1040 /* There is alot of memory leaks but this is simply a test program.