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 #define MAX_BUFFER 1024
62 char* WtoA( OLECHAR
* p
)
64 static char buffer
[MAX_BUFFER
];
65 DWORD len
= WideCharToMultiByte( CP_ACP
, 0, p
, -1, buffer
+1, sizeof(buffer
)-3, NULL
, NULL
);
72 OLECHAR
* AtoW( char* p
)
75 DWORD len
= MultiByteToWideChar( CP_ACP
, 0, p
, -1, NULL
, 0 );
76 buffer
= malloc( len
* sizeof(OLECHAR
) );
77 MultiByteToWideChar( CP_ACP
, 0, p
, -1, buffer
, len
);
82 int PASCAL
WinMain (HINSTANCE inst
, HINSTANCE prev
, LPSTR cmdline
, int show
)
93 VARIANT_BOOL
* pBool
= &b
;
94 unsigned short uShort
= 0;
95 unsigned short* pUShort
= &uShort
;
96 unsigned long uLong
= 0;
97 unsigned long* pULong
= &uLong
;
99 CHAR
* pChar
= &theChar
;
109 double* pDouble
= &d
;
111 unsigned short i
= 0;
116 OLECHAR
* pOleChar
[120];
118 pOleChar
[0] = AtoW( "-2" );
119 pOleChar
[1] = AtoW( "-1" );
120 pOleChar
[2] = AtoW( "-0.51" );
121 pOleChar
[3] = AtoW( "-0.5" );
122 pOleChar
[4] = AtoW( "-0.49" );
123 pOleChar
[5] = AtoW( "-0.0" );
124 pOleChar
[6] = AtoW( "0.0" );
125 pOleChar
[7] = AtoW( "0.49" );
126 pOleChar
[8] = AtoW( "0.5" );
127 pOleChar
[9] = AtoW( "0.51" );
128 pOleChar
[10] = AtoW( "1" );
129 pOleChar
[11] = AtoW( "127" );
130 pOleChar
[12] = AtoW( "128" );
131 pOleChar
[13] = AtoW( "129" );
132 pOleChar
[14] = AtoW( "255" );
133 pOleChar
[15] = AtoW( "256" );
134 pOleChar
[16] = AtoW( "257" );
135 pOleChar
[17] = AtoW( "32767" );
136 pOleChar
[18] = AtoW( "32768" );
137 pOleChar
[19] = AtoW( "-32768" );
138 pOleChar
[20] = AtoW( "-32769" );
139 pOleChar
[21] = AtoW( "16777216" );
140 pOleChar
[22] = AtoW( "16777217" );
141 pOleChar
[23] = AtoW( "-16777216" );
142 pOleChar
[24] = AtoW( "16777217" );
143 pOleChar
[25] = AtoW( "2147483647" );
144 pOleChar
[26] = AtoW( "2147483648" );
145 pOleChar
[27] = AtoW( "-2147483647" );
146 pOleChar
[28] = AtoW( "-2147483648" );
148 pOleChar
[29] = AtoW( "" );
149 pOleChar
[30] = AtoW( " " );
150 pOleChar
[31] = AtoW( "1F" );
151 pOleChar
[32] = AtoW( "1G" );
152 pOleChar
[33] = AtoW( " 1 " );
153 pOleChar
[34] = AtoW( " 1 2 " );
154 pOleChar
[35] = AtoW( "1,2,3" );
155 pOleChar
[36] = AtoW( "1 2 3" );
156 pOleChar
[37] = AtoW( "1,2, 3" );
157 pOleChar
[38] = AtoW( "1;2;3" );
158 pOleChar
[39] = AtoW( "1.2.3" );
160 pOleChar
[40] = AtoW( "0." );
161 pOleChar
[41] = AtoW( ".0" );
162 pOleChar
[42] = AtoW( "0.1E12" );
163 pOleChar
[43] = AtoW( "2.4,E1" );
164 pOleChar
[44] = AtoW( " +3.2,E1" );
165 pOleChar
[45] = AtoW( "4E2.5" );
166 pOleChar
[46] = AtoW( " 2E+2" );
167 pOleChar
[47] = AtoW( "1 E+2" );
168 pOleChar
[48] = AtoW( "." );
169 pOleChar
[49] = AtoW( ".E2" );
170 pOleChar
[50] = AtoW( "1000000000000000000000000000000000000000000000000000000000000000" );
171 pOleChar
[51] = AtoW( "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001" );
172 pOleChar
[52] = AtoW( "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001" );
173 pOleChar
[53] = AtoW( "100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001" );
174 pOleChar
[54] = AtoW( "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001" );
175 pOleChar
[55] = AtoW( "65535" );
176 pOleChar
[56] = AtoW( "65535.5" );
177 pOleChar
[57] = AtoW( "65536" );
178 pOleChar
[58] = AtoW( "4294967295" );
179 pOleChar
[59] = AtoW( "4294967296" );
181 pOleChar
[60] = AtoW( "1 January 99" );
182 pOleChar
[61] = AtoW( "December 31, 2078" );
183 pOleChar
[62] = AtoW( "January 1, 1900" );
184 pOleChar
[63] = AtoW( "January 2 1900" );
185 pOleChar
[64] = AtoW( "11.11.1999" );
186 pOleChar
[65] = AtoW( "11/11/1999" );
187 pOleChar
[66] = AtoW( " 11 / 11 / 1999" );
188 pOleChar
[67] = AtoW( "11/11/1999:11:11:1134" );
189 pOleChar
[68] = AtoW( "11/11/1999 11:11:11:1" );
190 pOleChar
[69] = AtoW( "\t1999/\t11/21 11 :11:11am" );
192 pOleChar
[70] = AtoW( "11/11/1999 11:11:11Am" );
193 pOleChar
[71] = AtoW( "11/11/1999 11:11:11PM" );
194 pOleChar
[72] = AtoW( "11/11/199911:11:11PM" );
195 pOleChar
[73] = AtoW( "11/11/1999 0:0:11am" );
196 pOleChar
[74] = AtoW( "11/11/1999 11,11:11am" );
197 pOleChar
[75] = AtoW( "11/11/1999 11:11:11am" );
198 pOleChar
[76] = AtoW( "11/11/1999 11/11:11am" );
199 pOleChar
[77] = AtoW( "11/11/1999 11:11AM" );
200 pOleChar
[78] = AtoW( "11/11/1999 1AM" );
201 pOleChar
[79] = AtoW( "11/11/1999 0AM" );
203 pOleChar
[80] = AtoW( "11/11/1999 11:11:11" );
204 pOleChar
[81] = AtoW( "11/13/1999 0AM" );
205 pOleChar
[82] = AtoW( "13/13/1999 0AM" );
206 pOleChar
[83] = AtoW( "13/11/1999 0AM" );
207 pOleChar
[84] = AtoW( "11/33/1999 0AM" );
208 pOleChar
[85] = AtoW( "11/11/1999 AM" );
209 pOleChar
[86] = AtoW( "1/1/0 0AM" );
210 pOleChar
[87] = AtoW( "1/1/-1 0AM" );
211 pOleChar
[88] = AtoW( "1999 January 3 9AM" );
212 pOleChar
[89] = AtoW( "1 January 1999 11AM" );
214 pOleChar
[90] = AtoW( "4AM 11/11/1999" );
215 pOleChar
[91] = AtoW( "4:22 11/11/1999 AM" );
216 pOleChar
[92] = AtoW( " 1 1 /11/1999" );
217 pOleChar
[93] = AtoW( "11-11/1999 11:11:11.12AM" );
218 pOleChar
[94] = AtoW( "1999 January 3, 9AM" );
219 pOleChar
[95] = AtoW( "December, 31, 2078" );
220 pOleChar
[96] = AtoW( "December, 31, 2078," );
221 pOleChar
[97] = AtoW( "December, 31 2078" );
222 pOleChar
[98] = AtoW( "11/99" );
223 pOleChar
[99] = AtoW( "11-1999" );
225 pOleChar
[100] = AtoW( "true" );
226 pOleChar
[101] = AtoW( "True" );
227 pOleChar
[102] = AtoW( "TRue" );
228 pOleChar
[103] = AtoW( "TRUE" );
229 pOleChar
[104] = AtoW( " TRUE" );
230 pOleChar
[105] = AtoW( "FALSE " );
231 pOleChar
[106] = AtoW( "False" );
232 pOleChar
[107] = AtoW( "JustSomeText" );
233 pOleChar
[108] = AtoW( "Just Some Text" );
234 pOleChar
[109] = AtoW( "" );
236 pOleChar
[110] = AtoW( "1.5" );
237 pOleChar
[111] = AtoW( "2.5" );
238 pOleChar
[112] = AtoW( "3.5" );
239 pOleChar
[113] = AtoW( "4.5" );
240 pOleChar
[114] = AtoW( "" );
241 pOleChar
[115] = AtoW( "" );
242 pOleChar
[116] = AtoW( "" );
243 pOleChar
[117] = AtoW( "" );
244 pOleChar
[118] = AtoW( "" );
245 pOleChar
[119] = AtoW( "" );
248 /* Start testing the Low-Level API ( the coercions )
252 /* unsigned char from...
254 printf( "\n\n======== Testing VarUI1FromXXX ========\n");
256 /* res = VarUI1FromI2( 0, NULL );
258 printf( "VarUI1FromI2: passing in NULL as return val makes it crash, %X\n", (unsigned int) res
);
260 res
= VarUI1FromStr( NULL
, 0, 0, pByte
);
261 printf( "VarUI1FromStr: passing in NULL as param: %X\n", (unsigned int) res
);
263 res
= VarUI1FromI2( 0, pByte
);
264 printf( "VarUI1FromI2: 0, %X, %X\n", *pByte
, (unsigned int) res
);
265 res
= VarUI1FromI2( 69, pByte
);
266 printf( "VarUI1FromI2: 69, %X, %X\n", *pByte
, (unsigned int) res
);
267 res
= VarUI1FromI2( 70, pByte
);
268 printf( "VarUI1FromI2: 70, %X, %X\n", *pByte
, (unsigned int) res
);
269 res
= VarUI1FromI2( 128, pByte
);
270 printf( "VarUI1FromI2: 128, %X, %X\n", *pByte
, (unsigned int) res
);
271 res
= VarUI1FromI2( 255, pByte
);
272 printf( "VarUI1FromI2: 255, %X, %X\n", *pByte
, (unsigned int) res
);
273 res
= VarUI1FromI2( 256, pByte
);
274 printf( "VarUI1FromI2: 256, %X, %X\n", *pByte
, (unsigned int) res
);
275 res
= VarUI1FromI2( 257, pByte
);
276 printf( "VarUI1FromI2: 257, %X, %X\n", *pByte
, (unsigned int) res
);
278 res
= VarUI1FromR8( 0.0, pByte
);
279 printf( "VarUI1FromR8: 0.0, %X, %X\n", *pByte
, (unsigned int) res
);
280 res
= VarUI1FromR8( 69.33, pByte
);
281 printf( "VarUI1FromR8: 69.33, %X, %X\n", *pByte
, (unsigned int) res
);
282 res
= VarUI1FromR8( 69.66, pByte
);
283 printf( "VarUI1FromR8: 69.66, %X, %X\n", *pByte
, (unsigned int) res
);
284 res
= VarUI1FromR8( -69.33, pByte
);
285 printf( "VarUI1FromR8: -69.33, %X, %X\n", *pByte
, (unsigned int) res
);
286 res
= VarUI1FromR8( -69.66, pByte
);
287 printf( "VarUI1FromR8: -69.66, %X, %X\n", *pByte
, (unsigned int) res
);
289 res
= VarUI1FromR8( -0.5, pByte
);
290 printf( "VarUI1FromR8: -0.5, %X, %X\n", *pByte
, (unsigned int) res
);
291 res
= VarUI1FromR8( -0.51, pByte
);
292 printf( "VarUI1FromR8: -0.51, %X, %X\n", *pByte
, (unsigned int) res
);
293 res
= VarUI1FromR8( -0.49, pByte
);
294 printf( "VarUI1FromR8: -0.49, %X, %X\n", *pByte
, (unsigned int) res
);
296 res
= VarUI1FromR8( 0.5, pByte
);
297 printf( "VarUI1FromR8: 0.5, %X, %X\n", *pByte
, (unsigned int) res
);
298 res
= VarUI1FromR8( 0.51, pByte
);
299 printf( "VarUI1FromR8: 0.51, %X, %X\n", *pByte
, (unsigned int) res
);
300 res
= VarUI1FromR8( 0.49, pByte
);
301 printf( "VarUI1FromR8: 0.49, %X, %X\n", *pByte
, (unsigned int) res
);
303 res
= VarUI1FromDate( 0.0, pByte
);
304 printf( "VarUI1FromDate: 0.0, %X, %X\n", *pByte
, (unsigned int) res
);
305 res
= VarUI1FromDate( 69.33, pByte
);
306 printf( "VarUI1FromDate: 69.33, %X, %X\n", *pByte
, (unsigned int) res
);
307 res
= VarUI1FromDate( 69.66, pByte
);
308 printf( "VarUI1FromDate: 69.66, %X, %X\n", *pByte
, (unsigned int) res
);
309 res
= VarUI1FromDate( -69.33, pByte
);
310 printf( "VarUI1FromDate: -69.33, %X, %X\n", *pByte
, (unsigned int) res
);
311 res
= VarUI1FromDate( -69.66, pByte
);
312 printf( "VarUI1FromDate: -69.66, %X, %X\n", *pByte
, (unsigned int) res
);
314 res
= VarUI1FromBool( VARIANT_TRUE
, pByte
);
315 printf( "VarUI1FromBool: VARIANT_TRUE, %X, %X\n", *pByte
, (unsigned int) res
);
316 res
= VarUI1FromBool( VARIANT_FALSE
, pByte
);
317 printf( "VarUI1FromBool: VARIANT_FALSE, %X, %X\n", *pByte
, (unsigned int) res
);
319 for( olePtrIndex
= 0; olePtrIndex
< nOlePtrs
; olePtrIndex
++ )
321 res
= VarUI1FromStr( pOleChar
[olePtrIndex
], 0, 0, pByte
);
322 printf( "VarUI1FromStr: %s, %X, %X\n", WtoA(pOleChar
[olePtrIndex
]), *pByte
, (unsigned int) res
);
326 /* unsigned short from ...
328 printf( "\n\n======== Testing VarUI2FromXXX ========\n");
330 res
= VarUI2FromI2( -1, &i
);
331 printf( "VarUI2FromI2: -1, %d, %X\n", i
, (unsigned int) res
);
333 /* res = VarUI2FromI2( 0, NULL );
335 printf( "VarUI2FromI2: passing in NULL as return val makes it crash, %X\n", (unsigned int) res
);
337 res
= VarUI2FromStr( NULL
, 0, 0, pUShort
);
338 printf( "VarUI2FromStr: passing in NULL as param: %X\n", (unsigned int) res
);
340 res
= VarUI2FromI2( 0, pUShort
);
341 printf( "VarUI2FromI2: 0, %u, %X\n", *pUShort
, (unsigned int) res
);
342 res
= VarUI2FromI2( 69, pUShort
);
343 printf( "VarUI2FromI2: 69, %u, %X\n", *pUShort
, (unsigned int) res
);
344 res
= VarUI2FromI2( 70, pUShort
);
345 printf( "VarUI2FromI2: 70, %u, %X\n", *pUShort
, (unsigned int) res
);
346 res
= VarUI2FromI2( 128, pUShort
);
347 printf( "VarUI2FromI2: 128, %u, %X\n", *pUShort
, (unsigned int) res
);
348 res
= VarUI2FromI4( 65535, pUShort
);
349 printf( "VarUI2FromI4: 65535, %u, %X\n", *pUShort
, (unsigned int) res
);
350 res
= VarUI2FromI4( 65536, pUShort
);
351 printf( "VarUI2FromI4: 65536, %u, %X\n", *pUShort
, (unsigned int) res
);
352 res
= VarUI2FromI4( 65537, pUShort
);
353 printf( "VarUI2FromI4: 65537, %u, %X\n", *pUShort
, (unsigned int) res
);
355 res
= VarUI2FromR8( 0.0, pUShort
);
356 printf( "VarUI2FromR8: 0.0, %u, %X\n", *pUShort
, (unsigned int) res
);
357 res
= VarUI2FromR8( 69.33, pUShort
);
358 printf( "VarUI2FromR8: 69.33, %u, %X\n", *pUShort
, (unsigned int) res
);
359 res
= VarUI2FromR8( 69.66, pUShort
);
360 printf( "VarUI2FromR8: 69.66, %u, %X\n", *pUShort
, (unsigned int) res
);
361 res
= VarUI2FromR8( -69.33, pUShort
);
362 printf( "VarUI2FromR8: -69.33, %u, %X\n", *pUShort
, (unsigned int) res
);
363 res
= VarUI2FromR8( -69.66, pUShort
);
364 printf( "VarUI2FromR8: -69.66, %u, %X\n", *pUShort
, (unsigned int) res
);
366 res
= VarUI2FromR8( -0.5, pUShort
);
367 printf( "VarUI2FromR8: -0.5, %u, %X\n", *pUShort
, (unsigned int) res
);
368 res
= VarUI2FromR8( -0.51, pUShort
);
369 printf( "VarUI2FromR8: -0.51, %u, %X\n", *pUShort
, (unsigned int) res
);
370 res
= VarUI2FromR8( -0.49, pUShort
);
371 printf( "VarUI2FromR8: -0.49, %u, %X\n", *pUShort
, (unsigned int) res
);
373 res
= VarUI2FromR8( 0.5, pUShort
);
374 printf( "VarUI2FromR8: 0.5, %u, %X\n", *pUShort
, (unsigned int) res
);
375 res
= VarUI2FromR8( 0.51, pUShort
);
376 printf( "VarUI2FromR8: 0.51, %u, %X\n", *pUShort
, (unsigned int) res
);
377 res
= VarUI2FromR8( 0.49, pUShort
);
378 printf( "VarUI2FromR8: 0.49, %u, %X\n", *pUShort
, (unsigned int) res
);
380 res
= VarUI2FromDate( 0.0, pUShort
);
381 printf( "VarUI2FromDate: 0.0, %u, %X\n", *pUShort
, (unsigned int) res
);
382 res
= VarUI2FromDate( 69.33, pUShort
);
383 printf( "VarUI2FromDate: 69.33, %u, %X\n", *pUShort
, (unsigned int) res
);
384 res
= VarUI2FromDate( 69.66, pUShort
);
385 printf( "VarUI2FromDate: 69.66, %u, %X\n", *pUShort
, (unsigned int) res
);
386 res
= VarUI2FromDate( -69.33, pUShort
);
387 printf( "VarUI2FromDate: -69.33, %u, %X\n", *pUShort
, (unsigned int) res
);
388 res
= VarUI2FromDate( -69.66, pUShort
);
389 printf( "VarUI2FromDate: -69.66, %u, %X\n", *pUShort
, (unsigned int) res
);
391 res
= VarUI2FromBool( VARIANT_TRUE
, pUShort
);
392 printf( "VarUI2FromBool: VARIANT_TRUE, %u, %X\n", *pUShort
, (unsigned int) res
);
393 res
= VarUI2FromBool( VARIANT_FALSE
, pUShort
);
394 printf( "VarUI2FromBool: VARIANT_FALSE, %u, %X\n", *pUShort
, (unsigned int) res
);
396 for( olePtrIndex
= 0; olePtrIndex
< nOlePtrs
; olePtrIndex
++ )
398 res
= VarUI2FromStr( pOleChar
[olePtrIndex
], 0, 0, pUShort
);
399 printf( "VarUI2FromStr: %s, %u, %X\n", WtoA(pOleChar
[olePtrIndex
]), (int)*pUShort
, (unsigned int) res
);
402 /* unsigned long from ...
404 printf( "\n\n======== Testing VarUI4FromXXX ========\n");
406 /*res = VarUI4FromI2( 0, NULL );
408 printf( "VarUI4FromI2: passing in NULL as return val makes it crash, %X\n", (unsigned int) res
);
410 res
= VarUI4FromStr( NULL
, 0, 0, pULong
);
411 printf( "VarUI4FromStr: passing in NULL as param: %X\n", (unsigned int) res
);
413 res
= VarUI4FromI2( 0, pULong
);
414 printf( "VarUI4FromI2: 0, %lu, %X\n", *pULong
, (unsigned int) res
);
415 res
= VarUI4FromI2( 69, pULong
);
416 printf( "VarUI4FromI2: 69, %lu, %X\n", *pULong
, (unsigned int) res
);
417 res
= VarUI4FromI2( 70, pULong
);
418 printf( "VarUI4FromI2: 70, %lu, %X\n", *pULong
, (unsigned int) res
);
419 res
= VarUI4FromI2( 128, pULong
);
420 printf( "VarUI4FromI2: 128, %lu, %X\n", *pULong
, (unsigned int) res
);
421 res
= VarUI4FromI2( 255, pULong
);
422 printf( "VarUI4FromI2: 255, %lu, %X\n", *pULong
, (unsigned int) res
);
423 res
= VarUI4FromR8( 4294967295.0, pULong
);
424 printf( "VarUI4FromR8: 4294967295, %lu, %X\n", *pULong
, (unsigned int) res
);
425 res
= VarUI4FromR8( 4294967296.0, pULong
);
426 printf( "VarUI4FromR8: 4294967296, %lu, %X\n", *pULong
, (unsigned int) res
);
428 res
= VarUI4FromR8( 0.0, pULong
);
429 printf( "VarUI4FromR8: 0.0, %lu, %X\n", *pULong
, (unsigned int) res
);
430 res
= VarUI4FromR8( 69.33, pULong
);
431 printf( "VarUI4FromR8: 69.33, %lu, %X\n", *pULong
, (unsigned int) res
);
432 res
= VarUI4FromR8( 69.66, pULong
);
433 printf( "VarUI4FromR8: 69.66, %lu, %X\n", *pULong
, (unsigned int) res
);
434 res
= VarUI4FromR8( -69.33, pULong
);
435 printf( "VarUI4FromR8: -69.33, %lu, %X\n", *pULong
, (unsigned int) res
);
436 res
= VarUI4FromR8( -69.66, pULong
);
437 printf( "VarUI4FromR8: -69.66, %lu, %X\n", *pULong
, (unsigned int) res
);
439 res
= VarUI4FromR8( -0.5, pULong
);
440 printf( "VarUI4FromR8: -0.5, %lu, %X\n", *pULong
, (unsigned int) res
);
441 res
= VarUI4FromR8( -0.51, pULong
);
442 printf( "VarUI4FromR8: -0.51, %lu, %X\n", *pULong
, (unsigned int) res
);
443 res
= VarUI4FromR8( -0.49, pULong
);
444 printf( "VarUI4FromR8: -0.49, %lu, %X\n", *pULong
, (unsigned int) res
);
446 res
= VarUI4FromR8( 0.5, pULong
);
447 printf( "VarUI4FromR8: 0.5, %lu, %X\n", *pULong
, (unsigned int) res
);
448 res
= VarUI4FromR8( 0.51, pULong
);
449 printf( "VarUI4FromR8: 0.51, %lu, %X\n", *pULong
, (unsigned int) res
);
450 res
= VarUI4FromR8( 0.49, pULong
);
451 printf( "VarUI4FromR8: 0.49, %lu, %X\n", *pULong
, (unsigned int) res
);
453 res
= VarUI4FromDate( 0.0, pULong
);
454 printf( "VarUI4FromDate: 0.0, %lu, %X\n", *pULong
, (unsigned int) res
);
455 res
= VarUI4FromDate( 69.33, pULong
);
456 printf( "VarUI4FromDate: 69.33, %lu, %X\n", *pULong
, (unsigned int) res
);
457 res
= VarUI4FromDate( 69.66, pULong
);
458 printf( "VarUI4FromDate: 69.66, %lu, %X\n", *pULong
, (unsigned int) res
);
459 res
= VarUI4FromDate( -69.33, pULong
);
460 printf( "VarUI4FromDate: -69.33, %lu, %X\n", *pULong
, (unsigned int) res
);
461 res
= VarUI4FromDate( -69.66, pULong
);
462 printf( "VarUI4FromDate: -69.66, %lu, %X\n", *pULong
, (unsigned int) res
);
464 res
= VarUI4FromBool( VARIANT_TRUE
, pULong
);
465 printf( "VarUI4FromBool: VARIANT_TRUE, %lu, %X\n", *pULong
, (unsigned int) res
);
466 res
= VarUI4FromBool( VARIANT_FALSE
, pULong
);
467 printf( "VarUI4FromBool: VARIANT_FALSE, %lu, %X\n", *pULong
, (unsigned int) res
);
469 for( olePtrIndex
= 0; olePtrIndex
< nOlePtrs
; olePtrIndex
++ )
471 res
= VarUI4FromStr( pOleChar
[olePtrIndex
], 0, 0, pULong
);
472 printf( "VarUI4FromStr: %s, %lu, %X\n", WtoA(pOleChar
[olePtrIndex
]), *pULong
, (unsigned int) res
);
477 printf( "\n\n======== Testing VarI1FromXXX ========\n");
479 res
= VarI1FromBool( VARIANT_TRUE
, pByte
);
480 printf( "VarI1FromBool: VARIANT_TRUE, %d, %X\n", *pByte
, (unsigned int) res
);
482 res
= VarI1FromBool( VARIANT_TRUE
, pChar
);
483 printf( "VarI1FromBool: VARIANT_TRUE, %d, %X\n", *pChar
, (unsigned int) res
);
485 res
= VarI1FromBool( VARIANT_FALSE
, pChar
);
486 printf( "VarI1FromBool: VARIANT_FALSE, %d, %X\n", *pChar
, (unsigned int) res
);
488 res
= VarI1FromUI1( (unsigned char)32767, pChar
);
489 printf( "VarI1FromUI1: 32767, %d, %X\n", *pChar
, (unsigned int) res
);
490 res
= VarI1FromUI1( (unsigned char)65535, pChar
);
491 printf( "VarI1FromUI1: 65535, %d, %X\n", *pChar
, (unsigned int) res
);
493 res
= VarI1FromI4( 32767, pChar
);
494 printf( "VarI1FromI4: 32767, %d, %X\n", *pChar
, (unsigned int) res
);
495 res
= VarI1FromI4( 32768, pChar
);
496 printf( "VarI1FromI4: 32768, %d, %X\n", *pChar
, (unsigned int) res
);
497 res
= VarI1FromI4( -32768, pChar
);
498 printf( "VarI1FromI4: -32768, %d, %X\n", *pChar
, (unsigned int) res
);
499 res
= VarI1FromI4( -32769, pChar
);
500 printf( "VarI1FromI4: -32769, %d, %X\n", *pChar
, (unsigned int) res
);
502 res
= VarI1FromR8( 69.33, pChar
);
503 printf( "VarI1FromR8: 69.33, %d, %X\n", *pChar
, (unsigned int) res
);
504 res
= VarI1FromR8( 69.66, pChar
);
505 printf( "VarI1FromR8: 69.66, %d, %X\n", *pChar
, (unsigned int) res
);
506 res
= VarI1FromR8( -69.33, pChar
);
507 printf( "VarI1FromR8: -69.33, %d, %X\n", *pChar
, (unsigned int) res
);
508 res
= VarI1FromR8( -69.66, pChar
);
509 printf( "VarI1FromR8: -69.66, %d, %X\n", *pChar
, (unsigned int) res
);
511 res
= VarI1FromDate( -69.66, pChar
);
512 printf( "VarI1FromDate: -69.66, %d, %X\n", *pChar
, (unsigned int) res
);
514 for( olePtrIndex
= 0; olePtrIndex
< nOlePtrs
; olePtrIndex
++ )
516 res
= VarI1FromStr( pOleChar
[olePtrIndex
], 0, 0, pChar
);
517 printf( "VarI1FromStr: %s, %d, %X\n", WtoA(pOleChar
[olePtrIndex
]), *pChar
, (unsigned int) res
);
522 printf( "\n\n======== Testing VarI2FromXXX ========\n");
524 res
= VarI2FromUI2( 32767, pShort
);
525 printf( "VarI2FromUI2: 32767, %d, %X\n", *pShort
, (unsigned int) res
);
526 res
= VarI2FromUI2( 65535, pShort
);
527 printf( "VarI2FromUI2: 65535, %d, %X\n", *pShort
, (unsigned int) res
);
529 res
= VarI2FromI4( 32767, pShort
);
530 printf( "VarI2FromI4: 32767, %d, %X\n", *pShort
, (unsigned int) res
);
531 res
= VarI2FromI4( 32768, pShort
);
532 printf( "VarI2FromI4: 32768, %d, %X\n", *pShort
, (unsigned int) res
);
533 res
= VarI2FromI4( -32768, pShort
);
534 printf( "VarI2FromI4: -32768, %d, %X\n", *pShort
, (unsigned int) res
);
535 res
= VarI2FromI4( -32769, pShort
);
536 printf( "VarI2FromI4: -32769, %d, %X\n", *pShort
, (unsigned int) res
);
538 res
= VarI2FromR8( 69.33, pShort
);
539 printf( "VarI2FromR8: 69.33, %d, %X\n", *pShort
, (unsigned int) res
);
540 res
= VarI2FromR8( 69.66, pShort
);
541 printf( "VarI2FromR8: 69.66, %d, %X\n", *pShort
, (unsigned int) res
);
542 res
= VarI2FromR8( -69.33, pShort
);
543 printf( "VarI2FromR8: -69.33, %d, %X\n", *pShort
, (unsigned int) res
);
544 res
= VarI2FromR8( -69.66, pShort
);
545 printf( "VarI2FromR8: -69.66, %d, %X\n", *pShort
, (unsigned int) res
);
547 res
= VarI2FromDate( -69.66, pShort
);
548 printf( "VarI2FromDate: -69.66, %d, %X\n", *pShort
, (unsigned int) res
);
550 for( olePtrIndex
= 0; olePtrIndex
< nOlePtrs
; olePtrIndex
++ )
552 res
= VarI2FromStr( pOleChar
[olePtrIndex
], 0, 0, pShort
);
553 printf( "VarI2FromStr: %s, %d, %X\n", WtoA(pOleChar
[olePtrIndex
]), *pShort
, (unsigned int) res
);
558 printf( "\n\n======== Testing VarI4FromXXX ========\n");
560 res
= VarI4FromI2( 3, (long*)pInt
);
561 printf( "VarIntFromI2: 3, %d, %X\n", *pInt
, (unsigned int) res
);
563 res
= VarI4FromR8( 69.33, pLong
);
564 printf( "VarI4FromR8: 69.33, %ld, %X\n", *pLong
, (unsigned int) res
);
565 res
= VarI4FromR8( 69.66, pLong
);
566 printf( "VarI4FromR8: 69.66, %ld, %X\n", *pLong
, (unsigned int) res
);
567 res
= VarI4FromR8( -69.33, pLong
);
568 printf( "VarI4FromR8: -69.33, %ld, %X\n", *pLong
, (unsigned int) res
);
569 res
= VarI4FromR8( -69.66, pLong
);
570 printf( "VarI4FromR8: -69.66, %ld, %X\n", *pLong
, (unsigned int) res
);
572 res
= VarI4FromR8( 2147483647.0, pLong
);
573 printf( "VarI4FromR8: 2147483647.0, %ld, %X\n", *pLong
, (unsigned int) res
);
574 res
= VarI4FromR8( 2147483648.0, pLong
);
575 printf( "VarI4FromR8: 2147483648.0, %ld, %X\n", *pLong
, (unsigned int) res
);
576 res
= VarI4FromR8( -2147483647.0, pLong
);
577 printf( "VarI4FromR8: -2147483647.0, %ld, %X\n", *pLong
, (unsigned int) res
);
578 res
= VarI4FromR8( -2147483648.0, pLong
);
579 printf( "VarI4FromR8: -2147483648.0, %ld, %X\n", *pLong
, (unsigned int) res
);
580 res
= VarI4FromR8( -2147483649.0, pLong
);
581 printf( "VarI4FromR8: -2147483649.0, %ld, %X\n", *pLong
, (unsigned int) res
);
583 res
= VarI4FromDate( -2147483649.0, pLong
);
584 printf( "VarI4FromDate: -2147483649.0, %ld, %X\n", *pLong
, (unsigned int) res
);
586 for( olePtrIndex
= 0; olePtrIndex
< nOlePtrs
; olePtrIndex
++ )
588 res
= VarI4FromStr( pOleChar
[olePtrIndex
], 0, 0, pLong
);
589 printf( "VarI4FromStr: %s, %ld, %X\n", WtoA(pOleChar
[olePtrIndex
]), *pLong
, (unsigned int) res
);
594 printf( "\n\n======== Testing VarR4FromXXX ========\n");
596 res
= VarR4FromI4( 16777216, pFloat
);
597 printf( "VarR4FromI4: 16777216, %f, %X\n", *pFloat
, (unsigned int) res
);
598 res
= VarR4FromI4( 16777217, pFloat
);
599 printf( "VarR4FromI4: 16777217, %f, %X\n", *pFloat
, (unsigned int) res
);
600 res
= VarR4FromI4( -16777216, pFloat
);
601 printf( "VarR4FromI4: -16777216, %f, %X\n", *pFloat
, (unsigned int) res
);
602 res
= VarR4FromI4( -16777217, pFloat
);
603 printf( "VarR4FromI4: -16777217, %f, %X\n", *pFloat
, (unsigned int) res
);
605 res
= VarR4FromR8( 16777216.0, pFloat
);
606 printf( "VarR4FromR8: 16777216.0, %f, %X\n", *pFloat
, (unsigned int) res
);
607 res
= VarR4FromR8( 16777217.0, pFloat
);
608 printf( "VarR4FromR8: 16777217.0, %f, %X\n", *pFloat
, (unsigned int) res
);
609 res
= VarR4FromR8( -16777216.0, pFloat
);
610 printf( "VarR4FromR8: -16777216.0, %f, %X\n", *pFloat
, (unsigned int) res
);
611 res
= VarR4FromR8( -16777217.0, pFloat
);
612 printf( "VarR4FromR8: -16777217.0, %f, %X\n", *pFloat
, (unsigned int) res
);
614 res
= VarR4FromR8( 16777218e31
, pFloat
);
615 printf( "VarR4FromR8: 16777218e31, %f, %X\n", *pFloat
, (unsigned int) res
);
616 res
= VarR4FromR8( 16777218e32
, pFloat
);
617 printf( "VarR4FromR8: 16777218e32, %f, %X\n", *pFloat
, (unsigned int) res
);
619 res
= VarR4FromDate( 16777218e31
, pFloat
);
620 printf( "VarR4FromDate: 16777218e31, %f, %X\n", *pFloat
, (unsigned int) res
);
622 for( olePtrIndex
= 0; olePtrIndex
< nOlePtrs
; olePtrIndex
++ )
624 res
= VarR4FromStr( pOleChar
[olePtrIndex
], 0, 0, pFloat
);
625 printf( "VarR4FromStr: %s, %f, %X\n", WtoA(pOleChar
[olePtrIndex
]), *pFloat
, (unsigned int) res
);
630 printf( "\n\n======== Testing VarR8FromXXX ========\n");
632 res
= VarR8FromDate( 900719925474099.0, pDouble
);
633 printf( "VarR8FromDate: 900719925474099.0, %f, %X\n", *pDouble
, (unsigned int) res
);
635 for( olePtrIndex
= 0; olePtrIndex
< nOlePtrs
; olePtrIndex
++ )
637 res
= VarR8FromStr( pOleChar
[olePtrIndex
], 0, 0, pDouble
);
638 printf( "VarR8FromStr: %s, %f, %X\n", WtoA(pOleChar
[olePtrIndex
]), *pDouble
, (unsigned int) res
);
643 printf( "\n\n======== Testing VarDateFromXXX ========\n");
645 res
= VarDateFromI4( 2958465, pDouble
);
646 printf( "VarDateFromI4: 2958465, %f, %X\n", *pDouble
, (unsigned int) res
);
647 res
= VarDateFromI4( 2958466, pDouble
);
648 printf( "VarDateFromI4: 2958466, %f, %X\n", *pDouble
, (unsigned int) res
);
649 res
= VarDateFromI4( -657434, pDouble
);
650 printf( "VarDateFromI4: -657434, %f, %X\n", *pDouble
, (unsigned int) res
);
651 res
= VarDateFromI4( -657435, pDouble
);
652 printf( "VarDateFromI4: -657435, %f, %X\n", *pDouble
, (unsigned int) res
);
654 res
= VarDateFromR8( 2958465.9999, pDouble
);
655 printf( "VarDateFromR8: 2958465.9999, %f, %X\n", *pDouble
, (unsigned int) res
);
656 res
= VarDateFromR8( 2958466, pDouble
);
657 printf( "VarDateFromR8: 2958466, %f, %X\n", *pDouble
, (unsigned int) res
);
658 res
= VarDateFromR8( -657434.9999, pDouble
);
659 printf( "VarDateFromR8: -657434.9999, %f, %X\n", *pDouble
, (unsigned int) res
);
660 res
= VarDateFromR8( -657435, pDouble
);
661 printf( "VarDateFromR8: -657435, %f, %X\n", *pDouble
, (unsigned int) res
);
664 res
= VarDateFromR8( 0.0, pDouble
);
665 printf( "VarDateFromR8: 0.0, %f, %X\n", *pDouble
, (unsigned int) res
);
666 res
= VarDateFromR8( 1.0, pDouble
);
667 printf( "VarDateFromR8: 1.0, %f, %X\n", *pDouble
, (unsigned int) res
);
668 res
= VarDateFromR8( 2.25, pDouble
);
669 printf( "VarDateFromR8: 2.25, %f, %X\n", *pDouble
, (unsigned int) res
);
670 res
= VarDateFromR8( -2.0, pDouble
);
671 printf( "VarDateFromR8: -2.0, %f, %X\n", *pDouble
, (unsigned int) res
);
673 /* Need some parsing function in Linux to emulate this...
676 for( olePtrIndex
= 0; olePtrIndex
< nOlePtrs
; olePtrIndex
++ )
678 res
= VarDateFromStr( pOleChar
[olePtrIndex
], 0, 0, pDouble
);
679 printf( "VarDateFromStr: %s, %f, %X\n", WtoA(pOleChar
[olePtrIndex
]), *pDouble
, (unsigned int) res
);
684 printf( "\n\n======== Testing VarBoolFromXXX ========\n");
686 res
= VarBoolFromI4( 0, pBool
);
687 printf( "VarBoolFromI4: 0, %d, %X\n", *pBool
, (unsigned int) res
);
688 res
= VarBoolFromI4( 1, pBool
);
689 printf( "VarBoolFromI4: 1, %d, %X\n", *pBool
, (unsigned int) res
);
690 res
= VarBoolFromI4( -1, pBool
);
691 printf( "VarBoolFromI4: -1, %d, %X\n", *pBool
, (unsigned int) res
);
692 res
= VarBoolFromI4( 2, pBool
);
693 printf( "VarBoolFromI4: 2, %d, %X\n", *pBool
, (unsigned int) res
);
695 res
= VarBoolFromUI1( ' ', pBool
);
696 printf( "VarBoolFromUI1: ' ', %d, %X\n", *pBool
, (unsigned int) res
);
697 res
= VarBoolFromUI1( '\0', pBool
);
698 printf( "VarBoolFromUI1: '\\0', %d, %X\n", *pBool
, (unsigned int) res
);
699 res
= VarBoolFromUI1( 0x0000, pBool
);
700 printf( "VarBoolFromUI1: 0x0000, %d, %X\n", *pBool
, (unsigned int) res
);
701 res
= VarBoolFromUI1( (unsigned char)0xFFF, pBool
);
702 printf( "VarBoolFromUI1: 0xFFF, %d, %X\n", *pBool
, (unsigned int) res
);
703 res
= VarBoolFromUI1( (unsigned char)0xFFFF, pBool
);
704 printf( "VarBoolFromUI1: 0xFFFF, %d, %X\n", *pBool
, (unsigned int) res
);
706 res
= VarBoolFromR8( 0.0, pBool
);
707 printf( "VarBoolFromR8: 0.0, %d, %X\n", *pBool
, (unsigned int) res
);
708 res
= VarBoolFromR8( 1.1, pBool
);
709 printf( "VarBoolFromR8: 1.1, %d, %X\n", *pBool
, (unsigned int) res
);
710 res
= VarBoolFromR8( 0.5, pBool
);
711 printf( "VarBoolFromR8: 0.5, %d, %X\n", *pBool
, (unsigned int) res
);
712 res
= VarBoolFromR8( 0.49, pBool
);
713 printf( "VarBoolFromR8: 0.49, %d, %X\n", *pBool
, (unsigned int) res
);
714 res
= VarBoolFromR8( 0.51, pBool
);
715 printf( "VarBoolFromR8: 0.51, %d, %X\n", *pBool
, (unsigned int) res
);
716 res
= VarBoolFromR8( -0.5, pBool
);
717 printf( "VarBoolFromR8: -0.5, %d, %X\n", *pBool
, (unsigned int) res
);
718 res
= VarBoolFromR8( -0.49, pBool
);
719 printf( "VarBoolFromR8: -0.49, %d, %X\n", *pBool
, (unsigned int) res
);
720 res
= VarBoolFromR8( -0.51, pBool
);
721 printf( "VarBoolFromR8: -0.51, %d, %X\n", *pBool
, (unsigned int) res
);
724 for( olePtrIndex
= 0; olePtrIndex
< nOlePtrs
; olePtrIndex
++ )
726 res
= VarBoolFromStr( pOleChar
[olePtrIndex
], 0, 0, pBool
);
727 printf( "VarBoolFromStr: %s, %d, %X\n", WtoA(pOleChar
[olePtrIndex
]), *pBool
, (unsigned int) res
);
730 res
= VarI1FromBool( VARIANT_TRUE
, pByte
);
731 printf( "VarI1FromBool: VARIANT_TRUE, %d, %X\n", *pByte
, (unsigned int) res
);
733 res
= VarUI2FromI2( -1, &i
);
734 printf( "VarUI2FromI2: -1, %d, %X\n", i
, (unsigned int) res
);
739 printf( "\n\n======== Testing VarBSTRFromXXX ========\n");
743 res
= VarBstrFromI1( -100, 0, 0, &bstr
);
744 printf( "VarBstrFromI1: -100, %s, %X\n", WtoA( bstr
), (unsigned int) res
);
746 res
= VarBstrFromUI1( 0x5A, 0, 0, &bstr
);
747 printf( "VarBstrFromUI1: 0x5A, %s, %X\n", WtoA( bstr
), (unsigned int) res
);
749 res
= VarBstrFromI4( 2958465, 0, 0, &bstr
);
750 printf( "VarBstrFromI4: 2958465, %s, %X\n", WtoA( bstr
), (unsigned int) res
);
755 for( i
=0; i
<20; i
++ )
757 /* add an integer to the real number
759 d
+= ((i
%9)+1) * pow( 10, i
);
760 res
= VarBstrFromR8( d
, 0, 0, &bstr
);
761 printf( "VarBstrFromR8: %f, %s, %X\n", d
, WtoA( bstr
), (unsigned int) res
);
762 res
= VarBstrFromR8( -d
, 0, 0, &bstr
);
763 printf( "VarBstrFromR8: %f, %s, %X\n", -d
, WtoA( bstr
), (unsigned int) res
);
766 for( i
=0; i
<20; i
++ )
768 /* add a decimal to the real number
770 d
+= ((i
%9)+1) * pow( 10, (i
*-1) );
771 res
= VarBstrFromR8( d
, 0, 0, &bstr
);
772 printf( "VarBstrFromR8: %f, %s, %X\n", d
, WtoA( bstr
), (unsigned int) res
);
773 res
= VarBstrFromR8( d
-1, 0, 0, &bstr
);
774 printf( "VarBstrFromR8: %f, %s, %X\n", d
-1, WtoA( bstr
), (unsigned int) res
);
775 res
= VarBstrFromR8( -d
, 0, 0, &bstr
);
776 printf( "VarBstrFromR8: %f, %s, %X\n", -d
, WtoA( bstr
), (unsigned int) res
);
780 for( i
=0; i
<20; i
++ )
782 /* add an integer to the real number
784 d
+= ((i
%9)+1) * pow( 10, i
);
785 /* add a decimal to the real number
787 d
+= ((i
%9)+1) * pow( 10, (i
*-1) );
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
);
797 for( i
=0; i
<10; i
++ )
799 /* add an integer to the real number
801 d
+= ((i
%9)+1) * pow( 10, i
);
802 res
= VarBstrFromR4( (float)d
, 0, 0, &bstr
);
803 printf( "VarBstrFromR4: %f, %s, %X\n", d
, WtoA( bstr
), (unsigned int) res
);
804 res
= VarBstrFromR4( (float)-d
, 0, 0, &bstr
);
805 printf( "VarBstrFromR4: %f, %s, %X\n", -d
, WtoA( bstr
), (unsigned int) res
);
808 for( i
=0; i
<10; i
++ )
810 /* add a decimal to the real number
812 d
+= ((i
%9)+1) * pow( 10, (i
*-1) );
813 res
= VarBstrFromR4( (float)d
, 0, 0, &bstr
);
814 printf( "VarBstrFromR4: %f, %s, %X\n", d
, WtoA( bstr
), (unsigned int) res
);
815 res
= VarBstrFromR4( (float)d
-1, 0, 0, &bstr
);
816 printf( "VarBstrFromR4: %f, %s, %X\n", d
-1, WtoA( bstr
), (unsigned int) res
);
817 res
= VarBstrFromR4( (float)-d
, 0, 0, &bstr
);
818 printf( "VarBstrFromR4: %f, %s, %X\n", -d
, WtoA( bstr
), (unsigned int) res
);
822 for( i
=0; i
<10; i
++ )
824 /* add an integer to the real number
826 d
+= ((i
%9)+1) * pow( 10, i
);
827 /* add a decimal to the real number
829 d
+= ((i
%9)+1) * pow( 10, (i
*-1) );
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
);
836 res
= VarBstrFromBool( 0x00, 0, 0, &bstr
);
837 printf( "VarBstrFromBool: 0x00, %s, %X\n", WtoA( bstr
), (unsigned int) res
);
838 res
= VarBstrFromBool( 0xFF, 0, 0, &bstr
);
839 printf( "VarBstrFromBool: 0xFF, %s, %X\n", WtoA( bstr
), (unsigned int) res
);
841 res
= VarBstrFromDate( 0.0, 0, 0, &bstr
);
842 printf( "VarBstrFromDate: 0.0, %s, %X\n", WtoA( bstr
), (unsigned int) res
);
843 res
= VarBstrFromDate( 3.34, 0, 0, &bstr
);
844 printf( "VarBstrFromDate: 3.34, %s, %X\n", WtoA( bstr
), (unsigned int) res
);
845 res
= VarBstrFromDate( 3339.34, 0, 0, &bstr
);
846 printf( "VarBstrFromDate: 3339.34, %s, %X\n", WtoA( bstr
), (unsigned int) res
);
847 res
= VarBstrFromDate( 365.00, 0, 0, &bstr
);
848 printf( "VarBstrFromDate: 365.00, %s, %X\n", WtoA( bstr
), (unsigned int) res
);
849 res
= VarBstrFromDate( 365.25, 0, 0, &bstr
);
850 printf( "VarBstrFromDate: 365.25, %s, %X\n", WtoA( bstr
), (unsigned int) res
);
851 res
= VarBstrFromDate( 1461.0, 0, 0, &bstr
);
852 printf( "VarBstrFromDate: 1461.00, %s, %X\n", WtoA( bstr
), (unsigned int) res
);
853 res
= VarBstrFromDate( 1461.5, 0, 0, &bstr
);
854 printf( "VarBstrFromDate: 1461.5, %s, %X\n", WtoA( bstr
), (unsigned int) res
);
857 res
= VarBstrFromBool( 0x00, 0, 0, &bstr
);
858 printf( "VarBstrFromBool: 0x00, %s, %X\n", WtoA(bstr
), (unsigned int) res
);
859 res
= VarBstrFromBool( 0xFF, 0, 0, &bstr
);
860 printf( "VarBstrFromBool: 0xFF, %s, %X\n", WtoA(bstr
), (unsigned int) res
);
862 res
= VarBstrFromDate( 0.0, 0, 0, &bstr
);
863 printf( "VarBstrFromDate: 0.0, %s, %X\n", WtoA(bstr
), (unsigned int) res
);
864 res
= VarBstrFromDate( 3.34, 0, 0, &bstr
);
865 printf( "VarBstrFromDate: 3.34, %s, %X\n", WtoA(bstr
), (unsigned int) res
);
867 /* Test variant API...
869 printf( "\n\n======== Testing Hi-Level Variant API ========\n");
871 bstr
= SysAllocString( pOleChar
[4] );
873 res
= VariantClear( &va
);
874 printf( "Result is: %x\n", (unsigned int)res
);
884 res
= VariantClear( &va
);
885 printf( "VariantClear: %x\n", (unsigned int)res
);
886 printf( "VariantClear: %x\n", (unsigned int)res
);
887 SysFreeString( bstr
);
888 SysFreeString( bstr
);
890 res
= VariantCopy( &vb
, &va
);
891 printf( "VariantCopy: %x\n", (unsigned int)res
);
892 res
= VariantClear( &vb
);
893 printf( "VariantClear: %x\n", (unsigned int)res
);
894 res
= VariantClear( &va
);
895 printf( "VariantClear: %x\n", (unsigned int)res
);
901 res
= VariantCopy( &va
, &va
);
902 printf( "VariantCopy %f -> %f: %x\n", V_R8(&va
), V_R8(&va
), (unsigned int)res
);
904 va
.vt
= VT_R8
| VT_BYREF
;
907 res
= VariantCopyInd( &va
, &va
);
908 printf( "VariantCopyInd %f: %x\n", V_R8(&va
), (unsigned int)res
);
913 res
= VariantCopy( &vb
, &va
);
914 printf( "VariantCopy %f -> %f: %x\n", V_R8(&va
), V_R8(&vb
), (unsigned int)res
);
916 va
.vt
= VT_R8
| VT_BYREF
;
919 res
= VariantCopy( &vb
, &va
);
920 printf( "VariantCopy %f -> %f: %x\n", *(V_R8REF(&va
)), *(V_R8REF(&vb
)), (unsigned int)res
);
922 va
.vt
= VT_R8
| VT_BYREF
;
925 res
= VariantCopyInd( &vb
, &va
);
926 printf( "VariantCopyInd %f -> %f: %x\n", *(V_R8REF(&va
)), V_R8(&vb
), (unsigned int)res
);
928 va
.vt
= VT_R8
| VT_BYREF
;
931 res
= VariantChangeTypeEx( &va
, &va
, 0, 0, VT_I2
);
932 printf( "VariantChangeTypeEx %d: %x\n", V_I2(&va
), (unsigned int) res
);
936 res
= VariantChangeTypeEx(&vb
, &va
, 0, 0, VT_BSTR
);
937 printf( "VariantChangeTypeEx %d -> %s: %x\n", V_INT(&va
), WtoA(V_BSTR(&vb
)), (unsigned int)res
);
940 va
.u
.date
= 34465.332431;
941 res
= VariantChangeTypeEx(&vb
, &va
, 0, 0, VT_BSTR
);
942 printf( "VariantChangeTypeEx %f -> %s: %x\n", V_DATE(&va
), WtoA(V_BSTR(&vb
)), (unsigned int)res
);
947 res
= VariantChangeTypeEx(&vb
, &va
, 0, 0, VT_R8
);
948 printf( "VariantChangeTypeEx %s -> %f: %x\n", WtoA(V_BSTR(&va
)), V_R8(&vb
), (unsigned int)res
);
951 vc
.vt
= VT_BSTR
| VT_BYREF
;
952 vc
.u
.pbstrVal
= &bstr
;
953 vb
.vt
= VT_VARIANT
| VT_BYREF
;
955 va
.vt
= VT_VARIANT
| VT_BYREF
;
957 res
= VariantCopyInd( &vd
, &va
);
958 printf( "VariantCopyInd: %x\n", (unsigned int)res
);
960 /* test what happens when bad vartypes are passed in
962 printf( "-------------- Testing different VARTYPES ----------------\n" );
964 for( i
=0; i
<100; i
++ )
966 /* Trying to use variants that are set to be BSTR but
967 * do not contain a valid pointer makes the program crash
968 * in Windows so we will skip those. We do not need them
969 * anyway to illustrate the behavior.
977 res
= VariantCopyInd( &vb
, &va
);
978 printf( "VariantCopyInd: %d -> %x\n", i
, (unsigned int)res
);
980 va
.vt
= i
| VT_BYREF
;
983 res
= VariantCopyInd( &vb
, &va
);
984 printf( "VariantCopyInd: %d -> %x\n", i
, (unsigned int)res
);
989 res
= VariantChangeTypeEx( &vb
, &va
, 0, 0, i
);
990 printf( "VariantChangeTypeEx: %d -> %x\n", i
, (unsigned int)res
);
995 res
= VariantChangeTypeEx( &vb
, &va
, 0, 0, i
| VT_BYREF
);
996 printf( "VariantChangeTypeEx: VT_BYREF %d -> %x\n", i
, (unsigned int)res
);
1001 res
= VariantClear( &va
);
1002 printf( "VariantClear: %d -> %x\n", i
, (unsigned int)res
);
1006 res
= VariantClear( &va
);
1007 printf( "VariantClear: %x\n", (unsigned int)res
);
1008 res
= VariantClear( &vb
);
1009 printf( "VariantClear: %x\n", (unsigned int)res
);
1010 res
= VariantClear( &vc
);
1011 printf( "VariantClear: %x\n", (unsigned int)res
);
1012 res
= VariantClear( &vd
);
1013 printf( "VariantClear: %x\n", (unsigned int)res
);
1014 res
= VariantClear( &ve
);
1015 printf( "VariantClear: %x\n", (unsigned int)res
);
1018 /* There is alot of memory leaks but this is simply a test program.