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.
20 * This library is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU Lesser General Public
22 * License as published by the Free Software Foundation; either
23 * version 2.1 of the License, or (at your option) any later version.
25 * This library is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28 * Lesser General Public License for more details.
30 * You should have received a copy of the GNU Lesser General Public
31 * License along with this library; if not, write to the Free Software
32 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
35 * - The Variant structure in Windows has a non-named union. This means
36 * the member of the union are accessible simply by doing pVariant->pfltVal.
37 * With gcc it is not possible to have non-named union so it has been named
38 * 'u'. So it's members are accessible using this name like so
39 * pVariant->u.pfltVal. So if this program is compiled in Windows
40 * the references to 'u' will need to be take out of this file.
42 * - Also the printf is a little different so the format specifiers may
43 * need to be tweaked if this file is compile in Windows.
44 * Printf is also different in that it continues printing numbers
45 * even after there is no more significative digits left to print. These
46 * number are garbage and in windows they are set to zero but not
49 * - The VarDateFromStr is not implemented yet.
51 * - The date and floating point format may not be the exact same format has the one in
52 * windows depending on what the Internatinal setting are in windows.
75 #include "wine/test.h"
77 #define MAX_BUFFER 1024
79 static char* WtoA( OLECHAR* p )
81 static char buffer[MAX_BUFFER];
82 DWORD len = WideCharToMultiByte( CP_ACP, 0, p, -1, buffer+1, sizeof(buffer)-3, NULL, NULL );
89 static OLECHAR* AtoW( char* p )
92 DWORD len = MultiByteToWideChar( CP_ACP, 0, p, -1, NULL, 0 );
93 buffer = malloc( len * sizeof(OLECHAR) );
94 MultiByteToWideChar( CP_ACP, 0, p, -1, buffer, len );
98 static const struct _vartypes {
100 DWORD vcind1,vcind2,vcex1,vcex2;
102 {0, 0, 0x80070057, 0, 0x80020008 },
103 {1, 0, 0x80070057, 0, 0x80020008 },
104 {2, 0, 0, 0, 0x80020005 },
105 {3, 0, 0, 0, 0x80020005 },
106 {4, 0, 0, 0, 0x80020005 },
107 {5, 0, 0, 0, 0x80020005 },
108 {6, 0, 0, 0, 0x80020005 },
109 {7, 0, 0, 0, 0x80020005 },
110 {77,0x80020008, 0x80070057, 0x80020008, 0x80020008 },
111 {78,0x80020008, 0x80070057, 0x80020008, 0x80020008 },
112 {79,0x80020008, 0x80070057, 0x80020008, 0x80020008 },
113 {80,0x80020008, 0x80070057, 0x80020008, 0x80020008 },
114 {81,0x80020008, 0x80070057, 0x80020008, 0x80020008 },
115 {82,0x80020008, 0x80070057, 0x80020008, 0x80020008 },
116 {83,0x80020008, 0x80070057, 0x80020008, 0x80020008 },
117 {84,0x80020008, 0x80070057, 0x80020008, 0x80020008 },
118 {85,0x80020008, 0x80070057, 0x80020008, 0x80020008 },
119 {86,0x80020008, 0x80070057, 0x80020008, 0x80020008 },
120 {87,0x80020008, 0x80070057, 0x80020008, 0x80020008 },
121 {88,0x80020008, 0x80070057, 0x80020008, 0x80020008 },
122 {89,0x80020008, 0x80070057, 0x80020008, 0x80020008 },
123 {90,0x80020008, 0x80070057, 0x80020008, 0x80020008 },
124 {91,0x80020008, 0x80070057, 0x80020008, 0x80020008 },
125 {92,0x80020008, 0x80070057, 0x80020008, 0x80020008 },
126 {93,0x80020008, 0x80070057, 0x80020008, 0x80020008 },
127 {94,0x80020008, 0x80070057, 0x80020008, 0x80020008 },
128 {95,0x80020008, 0x80070057, 0x80020008, 0x80020008 },
129 {96,0x80020008, 0x80070057, 0x80020008, 0x80020008 },
130 {97,0x80020008, 0x80070057, 0x80020008, 0x80020008 },
131 {98,0x80020008, 0x80070057, 0x80020008, 0x80020008 },
132 {99,0x80020008, 0x80070057, 0x80020008, 0x80020008 },
135 static const char *strfromr8[] = {
166 "7.65432198765432e+15",
167 "-7.65432198765432e+15",
168 "8.76543219876543e+16",
169 "-8.76543219876543e+16",
170 "9.87654321987654e+17",
171 "-9.87654321987654e+17",
172 "1.98765432198765e+18",
173 "-1.98765432198765e+18",
174 "2.19876543219877e+19",
175 "-2.19876543219877e+19",
266 "7.65432198765432e+15",
267 "-7.65432198765432e+15",
268 "8.76543219876543e+16",
269 "-8.76543219876543e+16",
270 "9.87654321987654e+17",
271 "-9.87654321987654e+17",
272 "1.98765432198765e+18",
273 "-1.98765432198765e+18",
274 "2.19876543219877e+19",
275 "-2.19876543219877e+19",
310 "0.2345001", /* FIXME: should be 0.2345 ? */
337 "654322.2", /* FIXME: should be 654322.3 */
338 "-654322.2",/* FIXME: should be -654322.3 */
349 static const struct _strret_date {
354 { -2.000000, 0x80020005 },
355 { -2.000000, 0x80020005 },
356 { -2.000000, 0x80020005 },
357 { -2.000000, 0x80020005 },
358 { -2.000000, 0x80020005 },
359 { -2.000000, 0x80020005 },
364 { 0.035417, 0x80020005 },
365 { 0.035417, 0x80020005 },
366 { 0.035417, 0x80020005 },
367 { 0.035417, 0x80020005 },
368 { 0.035417, 0x80020005 },
369 { 0.035417, 0x80020005 },
370 { 0.035417, 0x80020005 },
371 { 0.035417, 0x80020005 },
372 { 0.035417, 0x80020005 },
373 { 0.035417, 0x80020005 },
374 { 0.035417, 0x80020005 },
375 { 0.035417, 0x80020005 },
376 { 0.035417, 0x80020005 },
377 { 0.035417, 0x80020005 },
378 { 0.035417, 0x80020005 },
379 { 0.035417, 0x80020005 },
380 { 0.035417, 0x80020005 },
381 { 0.035417, 0x80020005 },
382 { 0.035417, 0x80020005 },
383 { 0.035417, 0x80020005 },
384 { 0.035417, 0x80020005 },
385 { 0.035417, 0x80020005 },
386 { 0.035417, 0x80020005 },
387 { 0.035417, 0x80020005 },
392 { 37623.000000, 0x80020005 },
394 { 0.043090, 0x80020005 },
395 { 0.043090, 0x80020005 },
396 { 0.043090, 0x80020005 },
397 { 0.043090, 0x80020005 },
398 { 0.043090, 0x80020005 },
399 { 0.043090, 0x80020005 },
400 { 0.043090, 0x80020005 },
401 { 0.043090, 0x80020005 },
402 { 0.043090, 0x80020005 },
403 { 0.043090, 0x80020005 },
404 { 0.043090, 0x80020005 },
405 { 0.043090, 0x80020005 },
406 { 0.043090, 0x80020005 },
407 { 0.043090, 0x80020005 },
408 { 0.043090, 0x80020005 },
409 { 0.043090, 0x80020005 },
410 { 0.043090, 0x80020005 },
411 { 0.043090, 0x80020005 },
412 { 0.043090, 0x80020005 },
413 { 0.043090, 0x80020005 },
418 { 3.000000, 0x80020005 },
421 { 36475.000000, 0x80020005 },
422 { 36475.000000, 0x80020005 },
426 { 36475.966100, 0x80020005 },
428 { 36475.000127, 0x80020005 },
430 { 36475.466100, 0x80020005 },
436 { 36477.000000, 0x80020005 },
438 { 36477.000000, 0x80020005 },
439 { 36477.000000, 0x80020005 },
441 { 36526.000000, 0x80020005 },
445 { 36475.166667, 0x80020005 },
446 { 36475.166667, 0x80020005 },
447 { 36475.166667, 0x80020005 },
448 { 36475.166667, 0x80020005 },
450 { 65380.000000, 0x80020005 },
454 { 36465.000000, 0x80020005 },
455 { 36465.000000, 0x80020005 },
456 { 36465.000000, 0x80020005 },
457 { 36465.000000, 0x80020005 },
458 { 36465.000000, 0x80020005 },
459 { 36465.000000, 0x80020005 },
460 { 36465.000000, 0x80020005 },
461 { 36465.000000, 0x80020005 },
462 { 36465.000000, 0x80020005 },
463 { 36465.000000, 0x80020005 },
468 { 0.170139, 0x80020005 },
469 { 0.170139, 0x80020005 },
470 { 0.170139, 0x80020005 },
471 { 0.170139, 0x80020005 },
472 { 0.170139, 0x80020005 },
473 { 0.170139, 0x80020005 },
475 static const struct _strret_b {
484 { VARIANT_FALSE, 0 },
485 { VARIANT_FALSE, 0 },
508 { VARIANT_TRUE, 0x80020005 },
509 { VARIANT_TRUE, 0x80020005 },
510 { VARIANT_TRUE, 0x80020005 },
511 { VARIANT_TRUE, 0x80020005 },
513 { VARIANT_TRUE, 0x80020005 },
515 { VARIANT_TRUE, 0x80020005 },
516 { VARIANT_TRUE, 0x80020005 },
517 { VARIANT_TRUE, 0x80020005 },
518 { VARIANT_TRUE, 0x80020005 },
519 { VARIANT_FALSE, 0 },
520 { VARIANT_FALSE, 0 },
524 { VARIANT_TRUE, 0x80020005 },
526 { VARIANT_TRUE, 0x80020005 },
527 { VARIANT_TRUE, 0x80020005 },
528 { VARIANT_TRUE, 0x80020005 },
539 { VARIANT_TRUE, 0x80020005 },
540 { VARIANT_TRUE, 0x80020005 },
541 { VARIANT_TRUE, 0x80020005 },
542 { VARIANT_TRUE, 0x80020005 },
543 { VARIANT_TRUE, 0x80020005 },
544 { VARIANT_TRUE, 0x80020005 },
545 { VARIANT_TRUE, 0x80020005 },
546 { VARIANT_TRUE, 0x80020005 },
547 { VARIANT_TRUE, 0x80020005 },
548 { VARIANT_TRUE, 0x80020005 },
549 { VARIANT_TRUE, 0x80020005 },
550 { VARIANT_TRUE, 0x80020005 },
551 { VARIANT_TRUE, 0x80020005 },
552 { VARIANT_TRUE, 0x80020005 },
553 { VARIANT_TRUE, 0x80020005 },
554 { VARIANT_TRUE, 0x80020005 },
555 { VARIANT_TRUE, 0x80020005 },
556 { VARIANT_TRUE, 0x80020005 },
557 { VARIANT_TRUE, 0x80020005 },
558 { VARIANT_TRUE, 0x80020005 },
559 { VARIANT_TRUE, 0x80020005 },
560 { VARIANT_TRUE, 0x80020005 },
561 { VARIANT_TRUE, 0x80020005 },
562 { VARIANT_TRUE, 0x80020005 },
563 { VARIANT_TRUE, 0x80020005 },
564 { VARIANT_TRUE, 0x80020005 },
565 { VARIANT_TRUE, 0x80020005 },
566 { VARIANT_TRUE, 0x80020005 },
567 { VARIANT_TRUE, 0x80020005 },
568 { VARIANT_TRUE, 0x80020005 },
569 { VARIANT_TRUE, 0x80020005 },
570 { VARIANT_TRUE, 0x80020005 },
571 { VARIANT_TRUE, 0x80020005 },
572 { VARIANT_TRUE, 0x80020005 },
573 { VARIANT_TRUE, 0x80020005 },
574 { VARIANT_TRUE, 0x80020005 },
575 { VARIANT_TRUE, 0x80020005 },
576 { VARIANT_TRUE, 0x80020005 },
577 { VARIANT_TRUE, 0x80020005 },
578 { VARIANT_TRUE, 0x80020005 },
583 { VARIANT_TRUE, 0x80020005 },
584 { VARIANT_TRUE, 0x80020005 },
585 { VARIANT_FALSE, 0 },
586 { VARIANT_FALSE, 0x80020005 },
587 { VARIANT_FALSE, 0x80020005 },
588 { VARIANT_FALSE, 0x80020005 },
593 { VARIANT_TRUE, 0x80020005 },
594 { VARIANT_TRUE, 0x80020005 },
595 { VARIANT_TRUE, 0x80020005 },
596 { VARIANT_TRUE, 0x80020005 },
597 { VARIANT_TRUE, 0x80020005 },
598 { VARIANT_TRUE, 0x80020005 },
600 static const struct _strret_r8 {
623 { -32768.000000, 0 },
624 { -32769.000000, 0 },
625 { 16777216.000000, 0 },
626 { 16777217.000000, 0 },
627 { -16777216.000000, 0 },
628 { 16777217.000000, 0 },
629 { 2147483647.000000, 0 },
630 { 2147483648.000000, 0 },
631 { -2147483647.000000, 0 },
632 { -2147483648.000000, 0 },
633 { -2147483648.000000, 0x80020005 },
634 { -2147483648.000000, 0x80020005 },
635 { -2147483648.000000, 0x80020005 },
636 { -2147483648.000000, 0x80020005 },
638 { 1.000000, 0x80020005 },
640 { 123.000000, 0x80020005 },
641 { 123.000000, 0x80020005 },
642 { 123.000000, 0x80020005 },
643 { 123.000000, 0x80020005 },
646 { 100000000000.000000, 0 },
649 { 32.000000, 0x80020005 },
651 { 200.000000, 0x80020005 },
652 { 200.000000, 0x80020005 },
653 { 200.000000, 0x80020005 },
654 { 1000000000000000100000000000000000000000000000000000000000000000.000000, 0 },
657 { 99999999999999997000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.000000, 0 },
662 { 4294967295.000000, 0 },
663 { 4294967296.000000, 0 },
664 { 4294967296.000000, 0x80020005 },
665 { 4294967296.000000, 0x80020005 },
666 { 4294967296.000000, 0x80020005 },
667 { 4294967296.000000, 0x80020005 },
668 { 4294967296.000000, 0x80020005 },
669 { 4294967296.000000, 0x80020005 },
670 { 4294967296.000000, 0x80020005 },
671 { 4294967296.000000, 0x80020005 },
672 { 4294967296.000000, 0x80020005 },
673 { 4294967296.000000, 0x80020005 },
674 { 4294967296.000000, 0x80020005 },
675 { 4294967296.000000, 0x80020005 },
676 { 4294967296.000000, 0x80020005 },
677 { 4294967296.000000, 0x80020005 },
678 { 4294967296.000000, 0x80020005 },
679 { 4294967296.000000, 0x80020005 },
680 { 4294967296.000000, 0x80020005 },
681 { 4294967296.000000, 0x80020005 },
682 { 4294967296.000000, 0x80020005 },
683 { 4294967296.000000, 0x80020005 },
684 { 4294967296.000000, 0x80020005 },
685 { 4294967296.000000, 0x80020005 },
686 { 4294967296.000000, 0x80020005 },
687 { 4294967296.000000, 0x80020005 },
688 { 4294967296.000000, 0x80020005 },
689 { 4294967296.000000, 0x80020005 },
690 { 4294967296.000000, 0x80020005 },
691 { 4294967296.000000, 0x80020005 },
692 { 4294967296.000000, 0x80020005 },
693 { 4294967296.000000, 0x80020005 },
694 { 4294967296.000000, 0x80020005 },
695 { 4294967296.000000, 0x80020005 },
696 { 4294967296.000000, 0x80020005 },
697 { 4294967296.000000, 0x80020005 },
698 { 4294967296.000000, 0x80020005 },
699 { 4294967296.000000, 0x80020005 },
700 { 4294967296.000000, 0x80020005 },
701 { 4294967296.000000, 0x80020005 },
702 { 4294967296.000000, 0x80020005 },
703 { 4294967296.000000, 0x80020005 },
704 { 4294967296.000000, 0x80020005 },
705 { 4294967296.000000, 0x80020005 },
706 { 4294967296.000000, 0x80020005 },
707 { 4294967296.000000, 0x80020005 },
708 { 4294967296.000000, 0x80020005 },
709 { 4294967296.000000, 0x80020005 },
710 { 4294967296.000000, 0x80020005 },
711 { 4294967296.000000, 0x80020005 },
712 { 4294967296.000000, 0x80020005 },
713 { 4294967296.000000, 0x80020005 },
718 { 4.500000, 0x80020005 },
719 { 4.500000, 0x80020005 },
720 { 4.500000, 0x80020005 },
721 { 4.500000, 0x80020005 },
722 { 4.500000, 0x80020005 },
723 { 4.500000, 0x80020005 },
725 static const struct _strret_r4 {
748 { -32768.000000, 0 },
749 { -32769.000000, 0 },
750 { 16777216.000000, 0 },
751 { 16777216.000000, 0 },
752 { -16777216.000000, 0 },
753 { 16777216.000000, 0 },
754 { 2147483648.000000, 0 },
755 { 2147483648.000000, 0 },
756 { -2147483648.000000, 0 },
757 { -2147483648.000000, 0 },
758 { -2147483648.000000, 0x80020005 },
759 { -2147483648.000000, 0x80020005 },
760 { -2147483648.000000, 0x80020005 },
761 { -2147483648.000000, 0x80020005 },
763 { 1.000000, 0x80020005 },
765 { 123.000000, 0x80020005 },
766 { 123.000000, 0x80020005 },
767 { 123.000000, 0x80020005 },
768 { 123.000000, 0x80020005 },
771 { 99999997952.000000, 0 },
774 { 32.000000, 0x80020005 },
776 { 200.000000, 0x80020005 },
777 { 200.000000, 0x80020005 },
778 { 200.000000, 0x80020005 },
779 { 200.000000, 0x8002000A },
782 { 1.000000, 0x8002000A },
787 { 4294967296.000000, 0 },
788 { 4294967296.000000, 0 },
789 { 4294967296.000000, 0x80020005 },
790 { 4294967296.000000, 0x80020005 },
791 { 4294967296.000000, 0x80020005 },
792 { 4294967296.000000, 0x80020005 },
793 { 4294967296.000000, 0x80020005 },
794 { 4294967296.000000, 0x80020005 },
795 { 4294967296.000000, 0x80020005 },
796 { 4294967296.000000, 0x80020005 },
797 { 4294967296.000000, 0x80020005 },
798 { 4294967296.000000, 0x80020005 },
799 { 4294967296.000000, 0x80020005 },
800 { 4294967296.000000, 0x80020005 },
801 { 4294967296.000000, 0x80020005 },
802 { 4294967296.000000, 0x80020005 },
803 { 4294967296.000000, 0x80020005 },
804 { 4294967296.000000, 0x80020005 },
805 { 4294967296.000000, 0x80020005 },
806 { 4294967296.000000, 0x80020005 },
807 { 4294967296.000000, 0x80020005 },
808 { 4294967296.000000, 0x80020005 },
809 { 4294967296.000000, 0x80020005 },
810 { 4294967296.000000, 0x80020005 },
811 { 4294967296.000000, 0x80020005 },
812 { 4294967296.000000, 0x80020005 },
813 { 4294967296.000000, 0x80020005 },
814 { 4294967296.000000, 0x80020005 },
815 { 4294967296.000000, 0x80020005 },
816 { 4294967296.000000, 0x80020005 },
817 { 4294967296.000000, 0x80020005 },
818 { 4294967296.000000, 0x80020005 },
819 { 4294967296.000000, 0x80020005 },
820 { 4294967296.000000, 0x80020005 },
821 { 4294967296.000000, 0x80020005 },
822 { 4294967296.000000, 0x80020005 },
823 { 4294967296.000000, 0x80020005 },
824 { 4294967296.000000, 0x80020005 },
825 { 4294967296.000000, 0x80020005 },
826 { 4294967296.000000, 0x80020005 },
827 { 4294967296.000000, 0x80020005 },
828 { 4294967296.000000, 0x80020005 },
829 { 4294967296.000000, 0x80020005 },
830 { 4294967296.000000, 0x80020005 },
831 { 4294967296.000000, 0x80020005 },
832 { 4294967296.000000, 0x80020005 },
833 { 4294967296.000000, 0x80020005 },
834 { 4294967296.000000, 0x80020005 },
835 { 4294967296.000000, 0x80020005 },
836 { 4294967296.000000, 0x80020005 },
837 { 4294967296.000000, 0x80020005 },
838 { 4294967296.000000, 0x80020005 },
843 { 4.500000, 0x80020005 },
844 { 4.500000, 0x80020005 },
845 { 4.500000, 0x80020005 },
846 { 4.500000, 0x80020005 },
847 { 4.500000, 0x80020005 },
848 { 4.500000, 0x80020005 },
850 static const struct _strret_i4 {
880 { 2147483647, 0x8002000A },
883 { -2147483648, 0x80020005 },
884 { -2147483648, 0x80020005 },
885 { -2147483648, 0x80020005 },
886 { -2147483648, 0x80020005 },
912 { 65536, 0x8002000A },
913 { 65536, 0x8002000A },
914 { 65536, 0x80020005 },
915 { 65536, 0x80020005 },
916 { 65536, 0x80020005 },
917 { 65536, 0x80020005 },
918 { 65536, 0x80020005 },
919 { 65536, 0x80020005 },
920 { 65536, 0x80020005 },
921 { 65536, 0x80020005 },
922 { 65536, 0x80020005 },
923 { 65536, 0x80020005 },
924 { 65536, 0x80020005 },
925 { 65536, 0x80020005 },
926 { 65536, 0x80020005 },
927 { 65536, 0x80020005 },
928 { 65536, 0x80020005 },
929 { 65536, 0x80020005 },
930 { 65536, 0x80020005 },
931 { 65536, 0x80020005 },
932 { 65536, 0x80020005 },
933 { 65536, 0x80020005 },
934 { 65536, 0x80020005 },
935 { 65536, 0x80020005 },
936 { 65536, 0x80020005 },
937 { 65536, 0x80020005 },
938 { 65536, 0x80020005 },
939 { 65536, 0x80020005 },
940 { 65536, 0x80020005 },
941 { 65536, 0x80020005 },
942 { 65536, 0x80020005 },
943 { 65536, 0x80020005 },
944 { 65536, 0x80020005 },
945 { 65536, 0x80020005 },
946 { 65536, 0x80020005 },
947 { 65536, 0x80020005 },
948 { 65536, 0x80020005 },
949 { 65536, 0x80020005 },
950 { 65536, 0x80020005 },
951 { 65536, 0x80020005 },
952 { 65536, 0x80020005 },
953 { 65536, 0x80020005 },
954 { 65536, 0x80020005 },
955 { 65536, 0x80020005 },
956 { 65536, 0x80020005 },
957 { 65536, 0x80020005 },
958 { 65536, 0x80020005 },
959 { 65536, 0x80020005 },
960 { 65536, 0x80020005 },
961 { 65536, 0x80020005 },
962 { 65536, 0x80020005 },
963 { 65536, 0x80020005 },
975 static const struct _strret_i2 {
997 { 32767, 0x8002000A },
999 { -32768, 0x8002000A },
1000 { -32768, 0x8002000A },
1001 { -32768, 0x8002000A },
1002 { -32768, 0x8002000A },
1003 { -32768, 0x8002000A },
1004 { -32768, 0x8002000A },
1005 { -32768, 0x8002000A },
1006 { -32768, 0x8002000A },
1007 { -32768, 0x8002000A },
1008 { -32768, 0x80020005 },
1009 { -32768, 0x80020005 },
1010 { -32768, 0x80020005 },
1011 { -32768, 0x80020005 },
1015 { 123, 0x80020005 },
1016 { 123, 0x80020005 },
1017 { 123, 0x80020005 },
1018 { 123, 0x80020005 },
1026 { 200, 0x80020005 },
1027 { 200, 0x80020005 },
1028 { 200, 0x80020005 },
1029 { 200, 0x8002000A },
1100 static const struct _strret_i1 {
1116 { 127, 0x8002000A },
1117 { 127, 0x8002000A },
1118 { 127, 0x8002000A },
1119 { 127, 0x8002000A },
1120 { 127, 0x8002000A },
1121 { 127, 0x8002000A },
1122 { 127, 0x8002000A },
1123 { 127, 0x8002000A },
1124 { 127, 0x8002000A },
1125 { 127, 0x8002000A },
1126 { 127, 0x8002000A },
1127 { 127, 0x8002000A },
1128 { 127, 0x8002000A },
1129 { 127, 0x8002000A },
1130 { 127, 0x8002000A },
1131 { 127, 0x8002000A },
1132 { 127, 0x8002000A },
1133 { 127, 0x80020005 },
1134 { 127, 0x80020005 },
1135 { 127, 0x80020005 },
1136 { 127, 0x80020005 },
1140 { 123, 0x80020005 },
1141 { 123, 0x80020005 },
1142 { 123, 0x80020005 },
1143 { 123, 0x80020005 },
1225 static const struct _strret_u1 {
1244 { 0xFF, 0x8002000A },
1245 { 0xFF, 0x8002000A },
1246 { 0xFF, 0x8002000A },
1247 { 0xFF, 0x8002000A },
1248 { 0xFF, 0x8002000A },
1249 { 0xFF, 0x8002000A },
1250 { 0xFF, 0x8002000A },
1251 { 0xFF, 0x8002000A },
1252 { 0xFF, 0x8002000A },
1253 { 0xFF, 0x8002000A },
1254 { 0xFF, 0x8002000A },
1255 { 0xFF, 0x8002000A },
1256 { 0xFF, 0x8002000A },
1257 { 0xFF, 0x8002000A },
1258 { 0xFF, 0x80020005 },
1259 { 0xFF, 0x80020005 },
1260 { 0xFF, 0x80020005 },
1261 { 0xFF, 0x80020005 },
1265 { 0x7B, 0x80020005 },
1266 { 0x7B, 0x80020005 },
1267 { 0x7B, 0x80020005 },
1268 { 0x7B, 0x80020005 },
1274 { 0x20, 0x80020005 },
1276 { 0xC8, 0x80020005 },
1277 { 0xC8, 0x80020005 },
1278 { 0xC8, 0x80020005 },
1279 { 0xC8, 0x8002000A },
1351 static const struct _strret_U2 {
1374 { 32768, 0x8002000A },
1375 { 32768, 0x8002000A },
1376 { 32768, 0x8002000A },
1377 { 32768, 0x8002000A },
1378 { 32768, 0x8002000A },
1379 { 32768, 0x8002000A },
1380 { 32768, 0x8002000A },
1381 { 32768, 0x8002000A },
1382 { 32768, 0x8002000A },
1383 { 32768, 0x8002000A },
1384 { 32768, 0x80020005 },
1385 { 32768, 0x80020005 },
1386 { 32768, 0x80020005 },
1387 { 32768, 0x80020005 },
1391 { 123, 0x80020005 },
1392 { 123, 0x80020005 },
1393 { 123, 0x80020005 },
1394 { 123, 0x80020005 },
1402 { 200, 0x80020005 },
1403 { 200, 0x80020005 },
1404 { 200, 0x80020005 },
1405 { 200, 0x8002000A },
1411 { 65535, 0x8002000A },
1412 { 65535, 0x8002000A },
1413 { 65535, 0x8002000A },
1414 { 65535, 0x8002000A },
1415 { 65535, 0x80020005 },
1416 { 65535, 0x80020005 },
1417 { 65535, 0x80020005 },
1418 { 65535, 0x80020005 },
1419 { 65535, 0x80020005 },
1420 { 65535, 0x80020005 },
1421 { 65535, 0x80020005 },
1422 { 65535, 0x80020005 },
1423 { 65535, 0x80020005 },
1424 { 65535, 0x80020005 },
1425 { 65535, 0x80020005 },
1426 { 65535, 0x80020005 },
1427 { 65535, 0x80020005 },
1428 { 65535, 0x80020005 },
1429 { 65535, 0x80020005 },
1430 { 65535, 0x80020005 },
1431 { 65535, 0x80020005 },
1432 { 65535, 0x80020005 },
1433 { 65535, 0x80020005 },
1434 { 65535, 0x80020005 },
1435 { 65535, 0x80020005 },
1436 { 65535, 0x80020005 },
1437 { 65535, 0x80020005 },
1438 { 65535, 0x80020005 },
1439 { 65535, 0x80020005 },
1440 { 65535, 0x80020005 },
1441 { 65535, 0x80020005 },
1442 { 65535, 0x80020005 },
1443 { 65535, 0x80020005 },
1444 { 65535, 0x80020005 },
1445 { 65535, 0x80020005 },
1446 { 65535, 0x80020005 },
1447 { 65535, 0x80020005 },
1448 { 65535, 0x80020005 },
1449 { 65535, 0x80020005 },
1450 { 65535, 0x80020005 },
1451 { 65535, 0x80020005 },
1452 { 65535, 0x80020005 },
1453 { 65535, 0x80020005 },
1454 { 65535, 0x80020005 },
1455 { 65535, 0x80020005 },
1456 { 65535, 0x80020005 },
1457 { 65535, 0x80020005 },
1458 { 65535, 0x80020005 },
1459 { 65535, 0x80020005 },
1460 { 65535, 0x80020005 },
1461 { 65535, 0x80020005 },
1462 { 65535, 0x80020005 },
1463 { 65535, 0x80020005 },
1464 { 65535, 0x80020005 },
1477 static const struct _strret_U4 {
1500 { 32768, 0x8002000A },
1501 { 32768, 0x8002000A },
1504 { 16777217, 0x8002000A },
1508 { 2147483648U, 0x8002000A },
1509 { 2147483648U, 0x8002000A },
1510 { 2147483648U, 0x80020005 },
1511 { 2147483648U, 0x80020005 },
1512 { 2147483648U, 0x80020005 },
1513 { 2147483648U, 0x80020005 },
1517 { 123, 0x80020005 },
1518 { 123, 0x80020005 },
1519 { 123, 0x80020005 },
1520 { 123, 0x80020005 },
1528 { 200, 0x80020005 },
1529 { 200, 0x80020005 },
1530 { 200, 0x80020005 },
1531 { 200, 0x8002000A },
1540 { 4294967295U, 0x8002000A },
1541 { 4294967295U, 0x80020005 },
1542 { 4294967295U, 0x80020005 },
1543 { 4294967295U, 0x80020005 },
1544 { 4294967295U, 0x80020005 },
1545 { 4294967295U, 0x80020005 },
1546 { 4294967295U, 0x80020005 },
1547 { 4294967295U, 0x80020005 },
1548 { 4294967295U, 0x80020005 },
1549 { 4294967295U, 0x80020005 },
1550 { 4294967295U, 0x80020005 },
1551 { 4294967295U, 0x80020005 },
1552 { 4294967295U, 0x80020005 },
1553 { 4294967295U, 0x80020005 },
1554 { 4294967295U, 0x80020005 },
1555 { 4294967295U, 0x80020005 },
1556 { 4294967295U, 0x80020005 },
1557 { 4294967295U, 0x80020005 },
1558 { 4294967295U, 0x80020005 },
1559 { 4294967295U, 0x80020005 },
1560 { 4294967295U, 0x80020005 },
1561 { 4294967295U, 0x80020005 },
1562 { 4294967295U, 0x80020005 },
1563 { 4294967295U, 0x80020005 },
1564 { 4294967295U, 0x80020005 },
1565 { 4294967295U, 0x80020005 },
1566 { 4294967295U, 0x80020005 },
1567 { 4294967295U, 0x80020005 },
1568 { 4294967295U, 0x80020005 },
1569 { 4294967295U, 0x80020005 },
1570 { 4294967295U, 0x80020005 },
1571 { 4294967295U, 0x80020005 },
1572 { 4294967295U, 0x80020005 },
1573 { 4294967295U, 0x80020005 },
1574 { 4294967295U, 0x80020005 },
1575 { 4294967295U, 0x80020005 },
1576 { 4294967295U, 0x80020005 },
1577 { 4294967295U, 0x80020005 },
1578 { 4294967295U, 0x80020005 },
1579 { 4294967295U, 0x80020005 },
1580 { 4294967295U, 0x80020005 },
1581 { 4294967295U, 0x80020005 },
1582 { 4294967295U, 0x80020005 },
1583 { 4294967295U, 0x80020005 },
1584 { 4294967295U, 0x80020005 },
1585 { 4294967295U, 0x80020005 },
1586 { 4294967295U, 0x80020005 },
1587 { 4294967295U, 0x80020005 },
1588 { 4294967295U, 0x80020005 },
1589 { 4294967295U, 0x80020005 },
1590 { 4294967295U, 0x80020005 },
1612 int* pInt = &theInt;
1614 VARIANT_BOOL* pBool = &b;
1615 unsigned short uShort = 0;
1616 unsigned short* pUShort = &uShort;
1617 unsigned long uLong = 0;
1618 unsigned long* pULong = &uLong;
1620 CHAR* pChar = &theChar;
1622 BYTE* pByte = &byte;
1626 long* pLong = &Long;
1630 double* pDouble = &d;
1635 OLECHAR* pOleChar[120];
1638 pOleChar[0] = AtoW( "-2" );
1639 pOleChar[1] = AtoW( "-1" );
1640 pOleChar[2] = AtoW( "-0.51" );
1641 pOleChar[3] = AtoW( "-0.5" );
1642 pOleChar[4] = AtoW( "-0.49" );
1643 pOleChar[5] = AtoW( "-0.0" );
1644 pOleChar[6] = AtoW( "0.0" );
1645 pOleChar[7] = AtoW( "0.49" );
1646 pOleChar[8] = AtoW( "0.5" );
1647 pOleChar[9] = AtoW( "0.51" );
1648 pOleChar[10] = AtoW( "1" );
1649 pOleChar[11] = AtoW( "127" );
1650 pOleChar[12] = AtoW( "128" );
1651 pOleChar[13] = AtoW( "129" );
1652 pOleChar[14] = AtoW( "255" );
1653 pOleChar[15] = AtoW( "256" );
1654 pOleChar[16] = AtoW( "257" );
1655 pOleChar[17] = AtoW( "32767" );
1656 pOleChar[18] = AtoW( "32768" );
1657 pOleChar[19] = AtoW( "-32768" );
1658 pOleChar[20] = AtoW( "-32769" );
1659 pOleChar[21] = AtoW( "16777216" );
1660 pOleChar[22] = AtoW( "16777217" );
1661 pOleChar[23] = AtoW( "-16777216" );
1662 pOleChar[24] = AtoW( "16777217" );
1663 pOleChar[25] = AtoW( "2147483647" );
1664 pOleChar[26] = AtoW( "2147483648" );
1665 pOleChar[27] = AtoW( "-2147483647" );
1666 pOleChar[28] = AtoW( "-2147483648" );
1668 pOleChar[29] = AtoW( "" );
1669 pOleChar[30] = AtoW( " " );
1670 pOleChar[31] = AtoW( "1F" );
1671 pOleChar[32] = AtoW( "1G" );
1672 pOleChar[33] = AtoW( " 1 " );
1673 pOleChar[34] = AtoW( " 1 2 " );
1674 pOleChar[35] = AtoW( "1,2,3" );
1675 pOleChar[36] = AtoW( "1 2 3" );
1676 pOleChar[37] = AtoW( "1,2, 3" );
1677 pOleChar[38] = AtoW( "1;2;3" );
1678 pOleChar[39] = AtoW( "1.2.3" );
1680 pOleChar[40] = AtoW( "0." );
1681 pOleChar[41] = AtoW( ".0" );
1682 pOleChar[42] = AtoW( "0.1E12" );
1683 pOleChar[43] = AtoW( "2.4,E1" );
1684 pOleChar[44] = AtoW( " +3.2,E1" );
1685 pOleChar[45] = AtoW( "4E2.5" );
1686 pOleChar[46] = AtoW( " 2E+2" );
1687 pOleChar[47] = AtoW( "1 E+2" );
1688 pOleChar[48] = AtoW( "." );
1689 pOleChar[49] = AtoW( ".E2" );
1690 pOleChar[50] = AtoW( "1000000000000000000000000000000000000000000000000000000000000000" );
1691 pOleChar[51] = AtoW( "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001" );
1692 pOleChar[52] = AtoW( "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001" );
1693 pOleChar[53] = AtoW( "100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001" );
1694 pOleChar[54] = AtoW( "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001" );
1695 pOleChar[55] = AtoW( "65535" );
1696 pOleChar[56] = AtoW( "65535.5" );
1697 pOleChar[57] = AtoW( "65536" );
1698 pOleChar[58] = AtoW( "4294967295" );
1699 pOleChar[59] = AtoW( "4294967296" );
1701 pOleChar[60] = AtoW( "1 January 99" );
1702 pOleChar[61] = AtoW( "December 31, 2078" );
1703 pOleChar[62] = AtoW( "January 1, 1900" );
1704 pOleChar[63] = AtoW( "January 2 1900" );
1705 pOleChar[64] = AtoW( "11.11.1999" );
1706 pOleChar[65] = AtoW( "11/11/1999" );
1707 pOleChar[66] = AtoW( " 11 / 11 / 1999" );
1708 pOleChar[67] = AtoW( "11/11/1999:11:11:1134" );
1709 pOleChar[68] = AtoW( "11/11/1999 11:11:11:1" );
1710 pOleChar[69] = AtoW( "\t1999/\t11/21 11 :11:11am" );
1712 pOleChar[70] = AtoW( "11/11/1999 11:11:11Am" );
1713 pOleChar[71] = AtoW( "11/11/1999 11:11:11PM" );
1714 pOleChar[72] = AtoW( "11/11/199911:11:11PM" );
1715 pOleChar[73] = AtoW( "11/11/1999 0:0:11am" );
1716 pOleChar[74] = AtoW( "11/11/1999 11,11:11am" );
1717 pOleChar[75] = AtoW( "11/11/1999 11:11:11am" );
1718 pOleChar[76] = AtoW( "11/11/1999 11/11:11am" );
1719 pOleChar[77] = AtoW( "11/11/1999 11:11AM" );
1720 pOleChar[78] = AtoW( "11/11/1999 1AM" );
1721 pOleChar[79] = AtoW( "11/11/1999 0AM" );
1723 pOleChar[80] = AtoW( "11/11/1999 11:11:11" );
1724 pOleChar[81] = AtoW( "11/13/1999 0AM" );
1725 pOleChar[82] = AtoW( "13/13/1999 0AM" );
1726 pOleChar[83] = AtoW( "13/11/1999 0AM" );
1727 pOleChar[84] = AtoW( "11/33/1999 0AM" );
1728 pOleChar[85] = AtoW( "11/11/1999 AM" );
1729 pOleChar[86] = AtoW( "1/1/0 0AM" );
1730 pOleChar[87] = AtoW( "1/1/-1 0AM" );
1731 pOleChar[88] = AtoW( "1999 January 3 9AM" );
1732 pOleChar[89] = AtoW( "1 January 1999 11AM" );
1734 pOleChar[90] = AtoW( "4AM 11/11/1999" );
1735 pOleChar[91] = AtoW( "4:22 11/11/1999 AM" );
1736 pOleChar[92] = AtoW( " 1 1 /11/1999" );
1737 pOleChar[93] = AtoW( "11-11/1999 11:11:11.12AM" );
1738 pOleChar[94] = AtoW( "1999 January 3, 9AM" );
1739 pOleChar[95] = AtoW( "December, 31, 2078" );
1740 pOleChar[96] = AtoW( "December, 31, 2078," );
1741 pOleChar[97] = AtoW( "December, 31 2078" );
1742 pOleChar[98] = AtoW( "11/99" );
1743 pOleChar[99] = AtoW( "11-1999" );
1745 pOleChar[100] = AtoW( "true" );
1746 pOleChar[101] = AtoW( "True" );
1747 pOleChar[102] = AtoW( "TRue" );
1748 pOleChar[103] = AtoW( "TRUE" );
1749 pOleChar[104] = AtoW( " TRUE" );
1750 pOleChar[105] = AtoW( "FALSE " );
1751 pOleChar[106] = AtoW( "False" );
1752 pOleChar[107] = AtoW( "JustSomeText" );
1753 pOleChar[108] = AtoW( "Just Some Text" );
1754 pOleChar[109] = AtoW( "" );
1756 pOleChar[110] = AtoW( "1.5" );
1757 pOleChar[111] = AtoW( "2.5" );
1758 pOleChar[112] = AtoW( "3.5" );
1759 pOleChar[113] = AtoW( "4.5" );
1760 pOleChar[114] = AtoW( "" );
1761 pOleChar[115] = AtoW( "" );
1762 pOleChar[116] = AtoW( "" );
1763 pOleChar[117] = AtoW( "" );
1764 pOleChar[118] = AtoW( "" );
1765 pOleChar[119] = AtoW( "" );
1768 /* Start testing the Low-Level API ( the coercions )
1772 /* unsigned char from...
1774 trace( "\n\n======== Testing VarUI1FromXXX ========\n");
1776 #define XOK "should return S_OK"
1777 #define XOV "should return DISP_E_OVERFLOW"
1778 /* ok(S_OK == VarUI1FromI2( 0, NULL ), XOK);
1780 trace( "VarUI1FromI2: passing in NULL as return val makes it crash, need to write proper test.\n" );
1782 ok(VarUI1FromStr(NULL,0,0,pByte) == DISP_E_TYPEMISMATCH,"should return DISP_E_TYPEMISMATCH");
1783 ok(S_OK == VarUI1FromI2( 0, pByte ), XOK);
1784 ok(*pByte == 0,"should give 0 byte value");
1786 ok(S_OK == VarUI1FromI2( 69, pByte ), XOK);
1787 ok(*pByte == 69,"should give 69 byte value");
1789 ok(S_OK == VarUI1FromI2( 70, pByte ), XOK);
1790 ok(*pByte == 70,"should give 70 byte value");
1792 ok(S_OK == VarUI1FromI2( 128, pByte ), XOK);
1793 ok(*pByte == 128,"should give 128 byte value");
1795 ok(S_OK == VarUI1FromI2( 255, pByte ), XOK);
1796 ok(*pByte == 255,"should give 255 byte value");
1798 ok(DISP_E_OVERFLOW == VarUI1FromI2( 256, pByte ), XOV);
1799 ok(DISP_E_OVERFLOW == VarUI1FromI2( 257, pByte ), XOV);
1801 ok(S_OK == VarUI1FromR8( 0.0, pByte ), XOK);
1802 ok(*pByte == 0,"0.0 float should be converted to 0");
1804 ok(S_OK == VarUI1FromR8( 69.33, pByte ), XOK);
1805 ok(*pByte == 0x45, "expected 69 (hex 0x45) as byte value");
1807 ok(S_OK == VarUI1FromR8( 69.66, pByte ), XOK);
1808 ok(*pByte == 0x46, "expected 70 (hex 0x46) as byte value");
1810 ok(DISP_E_OVERFLOW == VarUI1FromR8( -69.33, pByte ), XOV);
1811 ok(DISP_E_OVERFLOW == VarUI1FromR8( -69.66, pByte ), XOV);
1813 ok(S_OK == VarUI1FromR8( -0.5, pByte ), XOK);
1814 ok(*pByte == 0,"-0.5 should give return 0");
1816 ok(DISP_E_OVERFLOW == VarUI1FromR8( -0.51, pByte ), XOV);
1818 ok(S_OK == VarUI1FromR8( -0.49, pByte ), XOK);
1819 ok(*pByte == 0,"-0.49 should give return 0");
1821 ok(S_OK == VarUI1FromR8( 0.5, pByte ), XOK);
1822 ok(*pByte == 0,"0.5 should give return 0");
1824 ok(S_OK == VarUI1FromR8( 0.51, pByte ), XOK);
1825 ok(*pByte == 1,"0.51 should give return 1");
1827 ok(S_OK == VarUI1FromR8( 0.49, pByte ), XOK);
1828 ok(*pByte == 0,"0.49 should give return 0");
1830 ok(S_OK == VarUI1FromDate( 0.0, pByte ), XOK);
1831 ok(*pByte == 0,"0.0 date should give return 0");
1833 ok(S_OK == VarUI1FromDate( 69.33, pByte ), XOK);
1834 ok(*pByte == 0x45,"69.33 date should give return 0x45");
1836 ok(S_OK == VarUI1FromDate( 69.66, pByte ), XOK);
1837 ok(*pByte == 0x46,"69.66 date should give return 0x46");
1839 ok(DISP_E_OVERFLOW == VarUI1FromDate( -69.33, pByte ), XOV);
1841 ok(DISP_E_OVERFLOW == VarUI1FromDate( -69.66, pByte ), XOV);
1843 ok(S_OK == VarUI1FromBool( VARIANT_TRUE, pByte ), XOK);
1844 ok(*pByte == 0xff, "true should be converted to 0xff");
1846 ok(S_OK == VarUI1FromBool( VARIANT_FALSE, pByte ), XOK);
1847 ok(*pByte == 0, "false should be converted to 0");
1849 for( i = 0; i < nOlePtrs; i ++ )
1853 sprintf(msg,"offset %d was expecting return code %lx\n",i,strrets_U1[i].error);
1854 ok(strrets_U1[i].error == VarUI1FromStr( pOleChar[i], 0, 0, pByte ), msg);
1855 sprintf(msg,"offset %d was expecting return value %02x\n",i,strrets_U1[i].retval);
1856 ok(strrets_U1[i].retval == *pByte,msg);
1859 /* unsigned short from ... */
1860 trace( "\n\n======== Testing VarUI2FromXXX ========\n");
1862 ok(DISP_E_OVERFLOW == VarUI2FromI2( -1, pUShort ), XOV);
1863 /* ok(S_OK == VarUI2FromI2( 0, NULL ), XOK);
1865 trace("VarUI2FromI2: passing in NULL as return val makes it crash, needs to be fixed.\n");
1867 ok(DISP_E_TYPEMISMATCH == VarUI2FromStr( NULL, 0, 0, pUShort ), "should return DISP_E_TYPEMISMATCH");
1869 ok(S_OK == VarUI2FromI2( 0, pUShort ), XOK);
1870 ok(*pUShort == 0,"0 should be 0");
1871 ok(S_OK == VarUI2FromI2( 69, pUShort ), XOK);
1872 ok(*pUShort == 69,"69 should be 69");
1873 ok(S_OK == VarUI2FromI2( 70, pUShort ), XOK);
1874 ok(*pUShort == 70,"70 should be 70");
1876 ok(S_OK == VarUI2FromI2( 128, pUShort ), XOK);
1877 ok(*pUShort == 128,"128 should be 128");
1879 ok(S_OK == VarUI2FromI4( 65535, pUShort ), XOK);
1880 ok(*pUShort == 65535,"65535 should be 65535");
1881 ok(DISP_E_OVERFLOW == VarUI2FromI4( 65536, pUShort ), XOV);
1882 ok(DISP_E_OVERFLOW == VarUI2FromI4( 65537, pUShort ), XOV);
1883 ok(S_OK == VarUI2FromR8( 0.0, pUShort ), XOK);
1884 ok(*pUShort == 0,"0.0 should be 0");
1885 ok(S_OK == VarUI2FromR8( 69.33, pUShort ), XOK);
1886 ok(*pUShort == 69,"69.33 should be 69");
1887 ok(S_OK == VarUI2FromR8( 69.66, pUShort ), XOK);
1888 ok(*pUShort == 70,"69.66 should be 70");
1890 ok(DISP_E_OVERFLOW == VarUI2FromR8( -69.33, pUShort ), XOV);
1891 ok(DISP_E_OVERFLOW == VarUI2FromR8( -69.66, pUShort ), XOV);
1893 ok(S_OK == VarUI2FromR8( -0.5, pUShort ), XOK);
1894 ok(*pUShort == 0, "-0.5 -> 0");
1895 ok(DISP_E_OVERFLOW == VarUI2FromR8( -0.51, pUShort ), XOV);
1896 ok(S_OK == VarUI2FromR8( -0.49, pUShort ), XOK);
1897 ok(*pUShort == 0, "-0.49 -> 0");
1899 ok(S_OK == VarUI2FromR8( 0.5, pUShort ), XOK);
1900 ok(*pUShort == 0,"0.5 should be 0");
1901 ok(S_OK == VarUI2FromR8( 0.51, pUShort ), XOK);
1902 ok(*pUShort == 1,"0.51 should be 1");
1903 ok(S_OK == VarUI2FromR8( 0.49, pUShort ), XOK);
1904 ok(*pUShort == 0,"0.49 should be 0");
1906 ok(S_OK == VarUI2FromDate( 0.0, pUShort ), XOK);
1907 ok(*pUShort == 0,"0.0 should be 0");
1908 ok(S_OK == VarUI2FromDate( 69.33, pUShort ), XOK);
1909 ok(*pUShort == 69,"69.33 should be 69");
1910 ok(S_OK == VarUI2FromDate( 69.66, pUShort ), XOK);
1911 ok(*pUShort == 70,"69.66 should be 70");
1912 ok(DISP_E_OVERFLOW == VarUI2FromDate( -69.33, pUShort ), XOV);
1913 ok(DISP_E_OVERFLOW == VarUI2FromDate( -69.66, pUShort ), XOV);
1915 ok(S_OK == VarUI2FromBool( VARIANT_TRUE, pUShort ), XOK);
1916 ok(*pUShort == 65535,"TRUE should be 65535");
1917 ok(S_OK == VarUI2FromBool( VARIANT_FALSE, pUShort ), XOK);
1918 ok(*pUShort == 0,"FALSE should be 0");
1920 for( i = 0; i < nOlePtrs; i ++ )
1924 sprintf(msg,"offset %d, expecting error 0x%lx\n",i,strrets_U2[i].error);
1925 ok(strrets_U2[i].error == VarUI2FromStr( pOleChar[i], 0, 0, pUShort ), msg);
1926 sprintf(msg,"offset %d, expecting retval 0x%x\n",i,strrets_U2[i].retval);
1927 ok(strrets_U2[i].retval == *pUShort, msg);
1930 /* unsigned long from ...
1932 trace( "\n\n======== Testing VarUI4FromXXX ========\n");
1933 /*ok(S_OK == VarUI4FromI2( 0, NULL ), XOK);
1935 trace( "VarUI4FromI2: passing in NULL as return val makes it crash, implement me.\n");
1937 ok(DISP_E_TYPEMISMATCH == VarUI4FromStr( NULL, 0, 0, pULong ), "should erturn DISP_E_TYPEMISMATCH");
1939 ok(S_OK == VarUI4FromI2( 0, pULong ), XOK);
1940 ok(*pULong == 0,"0 should be 0");
1941 ok(S_OK == VarUI4FromI2( 69, pULong ), XOK);
1942 ok(*pULong == 69,"69 should be 69");
1944 ok(S_OK == VarUI4FromI2( 70, pULong ), XOK);
1945 ok(*pULong == 70,"70 should be 70");
1947 ok(S_OK == VarUI4FromI2( 128, pULong ), XOK);
1948 ok(*pULong == 128,"128 should be 128");
1949 ok(S_OK == VarUI4FromI2( 255, pULong ), XOK);
1950 ok(*pULong == 255,"255 should be 255");
1952 ok(S_OK == VarUI4FromR8( 4294967295.0, pULong ), XOK);
1953 ok(*pULong == 4294967295U,"4294967295.0 should be 4294967295");
1954 ok(DISP_E_OVERFLOW == VarUI4FromR8( 4294967296.0, pULong ), XOV);
1956 ok(S_OK == VarUI4FromR8( 0.0, pULong ), XOK);
1957 ok(*pULong == 0,"0 should be 0");
1958 ok(S_OK == VarUI4FromR8( 69.33, pULong ), XOK);
1959 ok(*pULong == 69,"69.33 should be 69");
1960 ok(S_OK == VarUI4FromR8( 69.66, pULong ), XOK);
1961 ok(*pULong == 70,"69.66 should be 70");
1962 ok(DISP_E_OVERFLOW == VarUI4FromR8( -69.33, pULong ), XOV);
1963 ok(DISP_E_OVERFLOW == VarUI4FromR8( -69.66, pULong ), XOV);
1965 ok(S_OK == VarUI4FromR8( -0.5, pULong ), XOK);
1966 ok(*pULong == 0,"-0.5 should be 0");
1968 ok(DISP_E_OVERFLOW == VarUI4FromR8( -0.51, pULong ), XOV);
1970 ok(S_OK == VarUI4FromR8( -0.49, pULong ), XOK);
1971 ok(*pULong == 0,"-0.49 should be 0");
1973 ok(S_OK == VarUI4FromR8( 0.5, pULong ), XOK);
1974 ok(*pULong == 0,"0.5 should be 0");
1975 ok(S_OK == VarUI4FromR8( 0.51, pULong ), XOK);
1976 ok(*pULong == 1,"0.51 should be 1");
1977 ok(S_OK == VarUI4FromR8( 0.49, pULong ), XOK);
1978 ok(*pULong == 0,"0.49 should be 0");
1980 ok(S_OK == VarUI4FromDate( 0.0, pULong ), XOK);
1981 ok(*pULong == 0,"0.0 should be 0");
1982 ok(S_OK == VarUI4FromDate( 69.33, pULong ), XOK);
1983 ok(*pULong == 69,"69.33 should be 69");
1984 ok(S_OK == VarUI4FromDate( 69.66, pULong ), XOK);
1985 ok(*pULong == 70,"69.66 should be 70");
1986 ok(DISP_E_OVERFLOW == VarUI4FromDate( -69.33, pULong ), XOV);
1987 ok(DISP_E_OVERFLOW == VarUI4FromDate( -69.66, pULong ), XOV);
1989 ok(S_OK == VarUI4FromBool( VARIANT_TRUE, pULong ), XOK);
1990 ok(*pULong == 4294967295U, "TRUE should be 4294967295");
1991 ok(S_OK == VarUI4FromBool( VARIANT_FALSE, pULong ), XOK);
1992 ok(*pULong == 0, "FALSE should be 0");
1994 for( i = 0; i < nOlePtrs; i ++ )
1998 sprintf(msg,"offset %d should return 0x%lx\n",i,
1999 strrets_U4[i].error);
2000 ok(strrets_U4[i].error == VarUI4FromStr( pOleChar[i], 0, 0, pULong ), msg);
2001 sprintf(msg,"offset %d should have retval 0x%lx\n",i,
2002 strrets_U4[i].retval);
2003 ok(*pULong == strrets_U4[i].retval,msg);
2008 trace( "\n\n======== Testing VarI1FromXXX ========\n");
2010 ok(S_OK == VarI1FromBool( VARIANT_TRUE, pByte ), XOK);
2011 ok(*pByte == 255, " TRUE should be 255");
2013 ok(S_OK == VarI1FromBool( VARIANT_TRUE, pChar ), XOK);
2014 ok(*pChar == -1, "TRUE should be -1");
2016 ok(S_OK == VarI1FromBool( VARIANT_FALSE, pChar ), XOK);
2017 ok(*pChar == 0, "FALSE should be 0");
2019 ok(DISP_E_OVERFLOW == VarI1FromUI1( (unsigned char)32767, pChar ), XOV);
2020 ok(*pChar == 0, "should still be 0");
2021 ok(DISP_E_OVERFLOW == VarI1FromUI1( (unsigned char)65535, pChar ), XOV);
2022 ok(*pChar == 0, "should still be 0");
2024 ok(DISP_E_OVERFLOW == VarI1FromI4( 32767, pChar ), XOV);
2025 ok(*pChar == 0, "should still be 0");
2026 ok(DISP_E_OVERFLOW == VarI1FromI4( 32768, pChar ), XOV);
2027 ok(*pChar == 0, "should still be 0");
2028 ok(DISP_E_OVERFLOW == VarI1FromI4( -32768, pChar ), XOV);
2029 ok(*pChar == 0, "should still be 0");
2030 ok(DISP_E_OVERFLOW == VarI1FromI4( -32769, pChar ), XOV);
2031 ok(*pChar == 0, "should still be 0");
2033 ok(S_OK == VarI1FromR8( 69.33, pChar ), XOK);
2034 ok(*pChar == 69, "69.33 should be 69");
2035 ok(S_OK == VarI1FromR8( 69.66, pChar ), XOK);
2036 ok(*pChar == 70, "69.66 should be 70");
2038 ok(S_OK == VarI1FromR8( -69.33, pChar ), XOK);
2039 ok(*pChar == -69, "-69.33 should be -69");
2040 ok(S_OK == VarI1FromR8( -69.66, pChar ), XOK);
2041 ok(*pChar == -70, "-69.66 should be -70");
2042 ok(S_OK == VarI1FromDate( -69.66, pChar ), XOK);
2043 ok(*pChar == -70, "-69.66 should be -70");
2045 for( i = 0; i < nOlePtrs; i ++ )
2049 sprintf(msg,"offset %d should return 0x%lx\n",i,strrets_I1[i].error);
2050 ok(strrets_I1[i].error == VarI1FromStr( pOleChar[i], 0, 0, pChar ), msg);
2051 sprintf(msg,"offset %d should have retval %d\n",i,strrets_I1[i].retval);
2052 ok(strrets_I1[i].retval == *pChar, msg);
2057 trace( "\n\n======== Testing VarI2FromXXX ========\n");
2059 ok(S_OK == VarI2FromUI2( 32767, pShort ), XOK);
2060 ok(*pShort == 32767, "should be 32767");
2061 ok(DISP_E_OVERFLOW == VarI2FromUI2( 65535, pShort ), XOV);
2062 ok(*pShort == 32767, "pShort should be unchanged");
2064 ok(S_OK == VarI2FromI4( 32767, pShort ), XOK);
2065 ok(*pShort == 32767, "should be 32767");
2066 ok(DISP_E_OVERFLOW == VarI2FromI4( 32768, pShort ), XOV);
2067 ok(*pShort == 32767, "should still be 32767");
2068 ok(S_OK == VarI2FromI4( -32768, pShort ), XOK);
2069 ok(*pShort == -32768, "should be -32768");
2070 ok(DISP_E_OVERFLOW == VarI2FromI4( -32769, pShort ), XOV);
2071 ok(*pShort == -32768, "should still be -32768");
2073 ok(S_OK == VarI2FromR8( 69.33, pShort ), XOK);
2074 ok(*pShort == 69, "should be 69");
2075 ok(S_OK == VarI2FromR8( 69.66, pShort ), XOK);
2076 ok(*pShort == 70, "should be 70");
2077 ok(S_OK == VarI2FromR8( -69.33, pShort ), XOK);
2078 ok(*pShort == -69, "should be -69");
2079 ok(S_OK == VarI2FromR8( -69.66, pShort ), XOK);
2080 ok(*pShort == -70, "should be -70");
2081 ok(S_OK == VarI2FromDate( -69.66, pShort ), XOK);
2082 ok(*pShort == -70, "should be -70");
2084 for( i = 0; i < nOlePtrs; i ++ )
2087 sprintf(msg,"offset %d, expected return 0x%lx",i,strrets_I2[i].error);
2088 ok(strrets_I2[i].error == VarI2FromStr( pOleChar[i], 0, 0, pShort ), msg);
2089 sprintf(msg,"offset %d, expect retval %d",i,strrets_I2[i].retval);
2090 ok(strrets_I2[i].retval == *pShort,msg);
2095 trace( "\n\n======== Testing VarI4FromXXX ========\n");
2097 ok(S_OK == VarI4FromI2( 3, (long*)pInt ), XOK);
2098 ok(*pInt == 3,"should be 3");
2100 ok(S_OK == VarI4FromR8( 69.33, pLong ), XOK);
2101 ok(*pLong == 69,"should be 69");
2102 ok(S_OK == VarI4FromR8( 69.66, pLong ), XOK);
2103 ok(*pLong == 70,"should be 70");
2104 ok(S_OK == VarI4FromR8( -69.33, pLong ), XOK);
2105 ok(*pLong == -69,"should be -69");
2106 ok(S_OK == VarI4FromR8( -69.66, pLong ), XOK);
2107 ok(*pLong == -70,"should be -70");
2109 ok(S_OK == VarI4FromR8( 2147483647.0, pLong ), XOK);
2110 ok(*pLong == 2147483647,"should be 2147483647");
2111 ok(DISP_E_OVERFLOW == VarI4FromR8( 2147483648.0, pLong ), XOV);
2112 ok(*pLong == 2147483647,"should still be 2147483647");
2114 ok(S_OK == VarI4FromR8( -2147483647.0, pLong ), XOK);
2115 ok(*pLong == -2147483647,"should be -2147483647");
2116 ok(S_OK == VarI4FromR8( -2147483648.0, pLong ), XOK);
2117 ok(*pLong == -2147483648,"should be -2147483648");
2118 ok(DISP_E_OVERFLOW == VarI4FromR8( -2147483649.0, pLong ), XOV);
2119 ok(*pLong == -2147483648,"should still be -2147483648");
2120 ok(DISP_E_OVERFLOW == VarI4FromDate( -2147483649.0, pLong ), XOV);
2121 ok(*pLong == -2147483648,"should still be -2147483648");
2123 for( i = 0; i < nOlePtrs; i ++ )
2127 sprintf(msg,"offset %d, should have retcode %lx",i,strrets_I4[i].error);
2128 ok(strrets_I4[i].error == VarI4FromStr( pOleChar[i], 0, 0, pLong ), msg);
2129 sprintf(msg,"offset %d, should have retval %ld",i,strrets_I4[i].retval);
2130 ok(strrets_I4[i].retval == *pLong,msg);
2135 trace( "\n\n======== Testing VarR4FromXXX ========\n");
2137 ok(S_OK == VarR4FromI4( 16777216, pFloat ), XOK);
2138 ok(16777216.0 == *pFloat,"should be 16777216.0");
2140 ok(S_OK == VarR4FromI4( 16777217, pFloat ), XOK);
2141 ok(16777216.0 == *pFloat,"should be 16777216.0");
2142 ok(S_OK == VarR4FromI4( -16777216, pFloat ), XOK);
2143 ok(-16777216.0 == *pFloat,"should be -16777216.0");
2144 ok(S_OK == VarR4FromI4( -16777217, pFloat ), XOK);
2145 ok(-16777216.0 == *pFloat,"should be -16777216.0");
2147 ok(S_OK == VarR4FromR8( 16777216.0, pFloat ), XOK);
2148 ok(16777216.0 == *pFloat,"should be 16777216.0");
2149 ok(S_OK == VarR4FromR8( 16777217.0, pFloat ), XOK);
2150 ok(16777216.0 == *pFloat,"should be 16777216.0");
2151 ok(S_OK == VarR4FromR8( -16777216.0, pFloat ), XOK);
2152 ok(-16777216.0 == *pFloat,"should be -16777216.0");
2153 ok(S_OK == VarR4FromR8( -16777217.0, pFloat ), XOK);
2154 ok(-16777216.0 == *pFloat,"should be -16777216.0");
2156 ok(S_OK == VarR4FromR8( 16777218e31, pFloat ), XOK);
2157 ok(*pFloat == 167772177736353110000000000000000000000.000000,
2158 "should be 167772177736353110000000000000000000000.000000");
2159 ok(DISP_E_OVERFLOW == VarR4FromR8( 16777218e32, pFloat ), XOV);
2160 ok(*pFloat == 167772177736353110000000000000000000000.000000,
2161 "should still be 167772177736353110000000000000000000000.000000");
2162 ok(S_OK == VarR4FromDate( 16777218e31, pFloat ), XOK);
2163 ok(*pFloat == 167772177736353110000000000000000000000.000000,
2164 "should be 167772177736353110000000000000000000000.000000");
2166 for( i = 0; i < nOlePtrs; i ++ )
2170 sprintf(msg,"offset %d, retcode should be 0x%08lx",i,strrets_R4[i].error);
2171 ok(strrets_R4[i].error == VarR4FromStr( pOleChar[i], 0, 0, pFloat ), msg);
2172 sprintf(msg,"offset %d, retval should be %f",i,strrets_R4[i].retval);
2173 ok(strrets_R4[i].retval == *pFloat,msg);
2178 trace( "\n\n======== Testing VarR8FromXXX ========\n");
2180 ok(S_OK == VarR8FromDate( 900719925474099.0, pDouble ), XOK);
2181 ok(*pDouble == 900719925474099.000000,"should be 900719925474099.000000\n");
2182 for( i = 0; i < nOlePtrs; i ++ )
2186 sprintf(msg,"offset %d, retcode should be 0x%lx",i,strrets_R8[i].error);
2187 ok(strrets_R8[i].error == VarR8FromStr( pOleChar[i], 0, 0, pDouble ), msg);
2188 sprintf(msg,"offset %d, retval should be %g",i,strrets_R8[i].retval);
2189 ok(strrets_R8[i].retval == *pDouble,msg);
2194 trace( "\n\n======== Testing VarDateFromXXX ========\n");
2196 ok(S_OK == VarDateFromI4( 2958465, pDouble ), XOK);
2197 ok(*pDouble == 2958465.000000,"should be 2958465.000000");
2198 ok(DISP_E_OVERFLOW == VarDateFromI4( 2958466, pDouble ), XOV);
2199 ok(*pDouble == 2958465.000000,"should still be 2958465.000000");
2200 ok(S_OK == VarDateFromI4( -657434, pDouble ), XOK);
2201 ok(*pDouble == -657434.000000,"should be -657434.000000");
2202 ok(DISP_E_OVERFLOW == VarDateFromI4( -657435, pDouble ), XOV);
2203 ok(*pDouble == -657434.000000,"should still be -657434.000000");
2205 ok(S_OK == VarDateFromR8( 2958465.9999, pDouble ), XOK);
2206 ok(*pDouble == 2958465.999900, "should be 2958465.999900");
2207 ok(DISP_E_OVERFLOW == VarDateFromR8( 2958466, pDouble ), XOV);
2208 ok(*pDouble == 2958465.999900, "should still be 2958465.999900");
2209 ok(S_OK == VarDateFromR8( -657434.9999, pDouble ), XOK);
2210 ok(*pDouble == -657434.999900,"should be -657434.999900");
2211 ok(DISP_E_OVERFLOW == VarDateFromR8( -657435, pDouble ), XOV);
2212 ok(*pDouble == -657434.999900,"should still be -657434.999900");
2214 ok(S_OK == VarDateFromR8( 0.0, pDouble ), XOK);
2215 ok(*pDouble == 0.0,"0.0 should be 0.0");
2216 ok(S_OK == VarDateFromR8( 1.0, pDouble ), XOK);
2217 ok(*pDouble == 1.0,"1.0 should be 1.0");
2218 ok(S_OK == VarDateFromR8( 2.25, pDouble ), XOK);
2219 ok(*pDouble == 2.25,"2.25 should be 2.25");
2220 ok(S_OK == VarDateFromR8( -2.0, pDouble ), XOK);
2221 ok(*pDouble == -2.0,"-2.0 should be -2.0");
2223 /* Need some parsing function in Linux to emulate this...
2226 #ifdef FIXED_DATE_FUNCTIONS
2227 for( i = 0; i < nOlePtrs; i ++ )
2232 retcode = VarDateFromStr( pOleChar[i], 0, 0, pDouble );
2233 sprintf(msg,"offset %d, string %s, retcode should be 0x%lx, but was 0x%lx",i,WtoA(pOleChar[i]),strrets_DATE[i].error,retcode);
2234 ok(strrets_DATE[i].error == retcode, msg);
2235 sprintf(msg,"offset %d, retval %g ",i,strrets_DATE[i].retval);
2236 ok(*pDouble == strrets_DATE[i].retval,msg);
2241 trace( "\n\n======== Testing VarBoolFromXXX ========\n");
2243 ok(S_OK == VarBoolFromI4( 0, pBool ), XOK);
2244 ok(VARIANT_FALSE == *pBool, "expected FALSE");
2245 ok(S_OK == VarBoolFromI4( 1, pBool ), XOK);
2246 ok(VARIANT_TRUE == *pBool, "expected TRUE");
2247 ok(S_OK == VarBoolFromI4( -1, pBool ), XOK);
2248 ok(VARIANT_TRUE == *pBool, "expected TRUE");
2249 ok(S_OK == VarBoolFromI4( 2, pBool ), XOK);
2250 ok(VARIANT_TRUE == *pBool, "expected TRUE");
2252 ok(S_OK == VarBoolFromUI1( ' ', pBool ), XOK);
2253 ok(VARIANT_TRUE == *pBool, "expected TRUE");
2254 ok(S_OK == VarBoolFromUI1( '\0', pBool ), XOK);
2255 ok(VARIANT_FALSE == *pBool, "expected FALSE");
2256 ok(S_OK == VarBoolFromUI1( 0x0000, pBool ), XOK);
2257 ok(VARIANT_FALSE == *pBool, "expected FALSE");
2258 ok(S_OK == VarBoolFromUI1( (unsigned char)0xFFF, pBool ), XOK);
2259 ok(VARIANT_TRUE == *pBool, "expected TRUE");
2260 ok(S_OK == VarBoolFromUI1( (unsigned char)0xFFFF, pBool ), XOK);
2261 ok(VARIANT_TRUE == *pBool, "expected TRUE");
2263 ok(S_OK == VarBoolFromR8( 0.0, pBool ), XOK);
2264 ok(VARIANT_FALSE == *pBool, "expected FALSE");
2265 ok(S_OK == VarBoolFromR8( 1.1, pBool ), XOK);
2266 ok(VARIANT_TRUE == *pBool, "expected TRUE");
2267 ok(S_OK == VarBoolFromR8( 0.5, pBool ), XOK);
2268 ok(VARIANT_TRUE == *pBool, "expected TRUE");
2269 ok(S_OK == VarBoolFromR8( 0.49, pBool ), XOK);
2270 ok(VARIANT_TRUE == *pBool, "expected TRUE");
2271 ok(S_OK == VarBoolFromR8( 0.51, pBool ), XOK);
2272 ok(VARIANT_TRUE == *pBool, "expected TRUE");
2273 ok(S_OK == VarBoolFromR8( -0.5, pBool ), XOK);
2274 ok(VARIANT_TRUE == *pBool, "expected TRUE");
2275 ok(S_OK == VarBoolFromR8( -0.49, pBool ), XOK);
2276 ok(VARIANT_TRUE == *pBool, "expected TRUE");
2277 ok(S_OK == VarBoolFromR8( -0.51, pBool ), XOK);
2278 ok(VARIANT_TRUE == *pBool, "expected TRUE");
2281 for( i = 0; i < nOlePtrs; i ++ )
2285 sprintf(msg,"offset %d, retcode should be 0x%lx",i,strrets_B[i].error);
2286 ok(strrets_B[i].error == VarBoolFromStr( pOleChar[i], 0, 0, pBool ), msg);
2287 sprintf(msg,"offset %d, retval should be 0x%x",i,strrets_B[i].retval);
2288 ok(strrets_B[i].retval == *pBool,msg);
2291 ok(S_OK == VarI1FromBool( VARIANT_TRUE, pByte ), XOK);
2292 ok(*pByte == 0xff,"true should be 0xff");
2293 ok(DISP_E_OVERFLOW == VarUI2FromI2( -1, pUShort ), XOV);
2297 trace( "\n\n======== Testing VarBSTRFromXXX ========\n");
2301 ok(S_OK == VarBstrFromI1( -100, 0, 0, &bstr ), XOK);
2302 ok(!strcmp(WtoA(bstr),"\"-100\""),"should be string -100");
2304 ok(S_OK == VarBstrFromUI1( 0x5A, 0, 0, &bstr ), XOK);
2305 ok(!strcmp(WtoA(bstr),"\"90\""),"should be string 90");
2306 ok(S_OK == VarBstrFromI4( 2958465, 0, 0, &bstr ), XOK);
2307 ok(!strcmp(WtoA(bstr),"\"2958465\""),"should be string 2958465");
2313 for( i=0; i<20; i++ )
2316 /* add an integer to the real number
2318 d += ((i%9)+1) * pow( 10, i );
2320 ok(S_OK == VarBstrFromR8( d, 0, 0, &bstr ), XOK);
2321 sprintf(msg,"d is %g, should be cvt. to %s, but return val is %s",d,strfromr8[off],WtoA(bstr));
2322 sprintf(xval,"\"%s\"",strfromr8[off]);
2323 ok(!strcmp(xval,WtoA(bstr)),msg);off++;
2325 ok(S_OK == VarBstrFromR8( -d, 0, 0, &bstr ), XOK);
2326 sprintf(msg,"d is %g, should be cvt. to %s, but return val is %s",-d,strfromr8[off],WtoA(bstr));
2327 sprintf(xval,"\"%s\"",strfromr8[off]);
2328 ok(!strcmp(xval,WtoA(bstr)),msg);off++;
2331 for( i=0; i<20; i++ )
2334 /* add a decimal to the real number
2336 d += ((i%9)+1) * pow( 10, (i*-1) );
2337 ok(S_OK == VarBstrFromR8( d, 0, 0, &bstr ), XOK);
2338 sprintf(msg,"d is %g, should be cvt. to %s, but return val is %s",d,strfromr8[off],WtoA(bstr));
2339 sprintf(xval,"\"%s\"",strfromr8[off]);
2340 ok(!strcmp(xval,WtoA(bstr)),msg);off++;
2341 ok(S_OK == VarBstrFromR8( d-1, 0, 0, &bstr ), XOK);
2342 sprintf(msg,"d is %g, should be cvt. to %s, but return val is %s",d-1,strfromr8[off],WtoA(bstr));
2343 sprintf(xval,"\"%s\"",strfromr8[off]);
2344 ok(!strcmp(xval,WtoA(bstr)),msg);off++;
2345 ok(S_OK == VarBstrFromR8( -d, 0, 0, &bstr ), XOK);
2346 sprintf(msg,"d is %g, should be cvt. to %s, but return val is %s",-d,strfromr8[off],WtoA(bstr));
2347 sprintf(xval,"\"%s\"",strfromr8[off]);
2348 ok(!strcmp(xval,WtoA(bstr)),msg);off++;
2352 for( i=0; i<20; i++ )
2355 /* add an integer to the real number
2357 d += ((i%9)+1) * pow( 10, i );
2358 /* add a decimal to the real number
2360 d += ((i%9)+1) * pow( 10, (i*-1) );
2361 ok(S_OK == VarBstrFromR8( d, 0, 0, &bstr ), XOK);
2362 sprintf(msg,"d is %g, should be cvt. to %s, but return val is %s",d,strfromr8[off],WtoA(bstr));
2363 sprintf(xval,"\"%s\"",strfromr8[off]);
2364 ok(!strcmp(xval,WtoA(bstr)),msg);off++;
2365 ok(S_OK == VarBstrFromR8( -d, 0, 0, &bstr ), XOK);
2366 sprintf(msg,"d is %g, should be cvt. to %s, but return val is %s",-d,strfromr8[off],WtoA(bstr));
2367 sprintf(xval,"\"%s\"",strfromr8[off]);
2368 ok(!strcmp(xval,WtoA(bstr)),msg);off++;
2374 for( i=0; i<10; i++ )
2377 /* add an integer to the real number
2379 d += ((i%9)+1) * pow( 10, i );
2380 ok(S_OK == VarBstrFromR4( (float)d, 0, 0, &bstr ), XOK);
2381 sprintf(msg,"d is %g, should be cvt. to %s, but return val is %s",d,strfromr8[off],WtoA(bstr));
2382 sprintf(xval,"\"%s\"",strfromr8[off]);
2383 ok(!strcmp(xval,WtoA(bstr)),msg);off++;
2384 ok(S_OK == VarBstrFromR4( (float)-d, 0, 0, &bstr ), XOK);
2385 sprintf(msg,"d is %g, should be cvt. to %s, but return val is %s",-d,strfromr8[off],WtoA(bstr));
2386 sprintf(xval,"\"%s\"",strfromr8[off]);
2387 ok(!strcmp(xval,WtoA(bstr)),msg);off++;
2390 for( i=0; i<10; i++ )
2393 /* add a decimal to the real number
2395 d += ((i%9)+1) * pow( 10, (i*-1) );
2396 ok(S_OK == VarBstrFromR4( (float)d, 0, 0, &bstr ), XOK);
2397 sprintf(msg,"d is %g, should be cvt. to %s, but return val is %s",d,strfromr8[off],WtoA(bstr));
2398 sprintf(xval,"\"%s\"",strfromr8[off]);
2399 ok(!strcmp(xval,WtoA(bstr)),msg);off++;
2400 ok(S_OK == VarBstrFromR4( (float)d-1, 0, 0, &bstr ), XOK);
2401 sprintf(msg,"d is %g, should be cvt. to %s, but return val is %s",d-1,strfromr8[off],WtoA(bstr));
2402 sprintf(xval,"\"%s\"",strfromr8[off]);
2403 ok(!strcmp(xval,WtoA(bstr)),msg);off++;
2404 ok(S_OK == VarBstrFromR4( (float)-d, 0, 0, &bstr ), XOK);
2405 sprintf(msg,"d is %g, should be cvt. to %s, but return val is %s",-d,strfromr8[off],WtoA(bstr));
2406 sprintf(xval,"\"%s\"",strfromr8[off]);
2407 ok(!strcmp(xval,WtoA(bstr)),msg);off++;
2411 for( i=0; i<10; i++ )
2414 /* add an integer to the real number
2416 d += ((i%9)+1) * pow( 10, i );
2417 /* add a decimal to the real number
2419 d += ((i%9)+1) * pow( 10, (i*-1) );
2420 ok(S_OK == VarBstrFromR4( (float)d, 0, 0, &bstr ), XOK);
2421 sprintf(msg,"d is %g, should be cvt. to %s, but return val is %s",d,strfromr8[off],WtoA(bstr));
2422 sprintf(xval,"\"%s\"",strfromr8[off]);
2423 ok(!strcmp(xval,WtoA(bstr)),msg);off++;
2424 ok(S_OK == VarBstrFromR4( (float)-d, 0, 0, &bstr ), XOK);
2425 sprintf(msg,"d is %g, should be cvt. to %s, but return val is %s",-d,strfromr8[off],WtoA(bstr));
2426 sprintf(xval,"\"%s\"",strfromr8[off]);
2427 ok(!strcmp(xval,WtoA(bstr)),msg);off++;
2430 ok(S_OK == VarBstrFromBool( 0x00, 0, 0, &bstr ), XOK);
2431 ok(!strcmp(WtoA(bstr),"\"False\""),"should be 'False'");
2432 ok(S_OK == VarBstrFromBool( 0xFF, 0, 0, &bstr ), XOK);
2433 ok(!strcmp(WtoA(bstr),"\"True\""),"should be 'True'");
2436 ok(S_OK == VarBstrFromDate( 0.0, 0, 0, &bstr ), XOK);
2437 sprintf(msg,"should be '12:00:00 AM', but is %s\n",WtoA(bstr));
2438 ok(!strcmp(WtoA(bstr),"\"12:00:00 AM\""),msg);
2441 ok(S_OK == VarBstrFromDate( 3.34, 0, 0, &bstr ), XOK);
2443 sprintf(msg,"should be '1/2/1900 8:09:36 AM', but is %s\n",WtoA(bstr));
2444 ok(!strcmp(WtoA(bstr),"\"1/2/1900 8:09:36 AM\""),msg);
2447 ok(S_OK == VarBstrFromDate( 3339.34, 0, 0, &bstr ), XOK);
2449 sprintf(msg,"should be '2/20/1909 8:09:36 AM', but is %s\n",WtoA(bstr));
2450 ok(!strcmp(WtoA(bstr),"\"2/20/1909 8:09:36 AM\""),msg);
2453 ok(S_OK == VarBstrFromDate( 365.00, 0, 0, &bstr ), XOK);
2455 sprintf(msg,"should be '12/30/1900', but is %s\n",WtoA(bstr));
2456 ok(!strcmp(WtoA(bstr),"\"12/30/1900\""),msg);
2459 ok(S_OK == VarBstrFromDate( 365.25, 0, 0, &bstr ), XOK);
2461 sprintf(msg,"should be '12/30/1900 6:00:00 AM', but is %s\n",WtoA(bstr));
2462 ok(!strcmp(WtoA(bstr),"\"12/30/1900 6:00:00 AM\""),msg);
2465 ok(S_OK == VarBstrFromDate( 1461.0, 0, 0, &bstr ), XOK);
2467 sprintf(msg,"should be '12/31/1903', but is %s\n",WtoA(bstr));
2468 ok(!strcmp(WtoA(bstr),"\"12/31/1903\""),msg);
2471 ok(S_OK == VarBstrFromDate( 1461.5, 0, 0, &bstr ), XOK);
2473 sprintf(msg,"should be '12/31/1903 12:00:00 PM', but is %s\n",WtoA(bstr));
2474 ok(!strcmp(WtoA(bstr),"\"12/31/1903 12:00:00 PM\""),msg);
2477 /* Test variant API...
2479 trace( "\n\n======== Testing Hi-Level Variant API ========\n");
2481 bstr = SysAllocString( pOleChar[4] );
2483 VariantClear( &va );
2491 V_VT(&va) = VT_BSTR;
2492 V_UNION(&va,bstrVal) = bstr;
2493 ok(S_OK == VariantClear( &va ), XOK);
2494 SysFreeString( bstr );
2495 SysFreeString( bstr );
2497 ok(S_OK == VariantCopy( &vb, &va ), XOK);
2498 ok(S_OK == VariantClear( &vb ), XOK);
2499 ok(S_OK == VariantClear( &va ), XOK);
2503 V_UNION(&va,dblVal) = d;
2504 ok(S_OK == VariantCopy( &va, &va ), XOK);
2505 ok(V_R8(&va) == 4.123,"should be 4.123");
2507 V_VT(&va) = VT_R8 | VT_BYREF;
2509 V_UNION(&va,pdblVal) = &d;
2510 ok(S_OK == VariantCopyInd( &va, &va ), XOK);
2511 ok(V_R8(&va) == 31.123,"should be 31.123");
2515 V_UNION(&va,dblVal) = d;
2516 ok(S_OK == VariantCopy( &vb, &va ), XOK);
2517 ok(V_R8(&vb) == 1.123,"should be 1.123");
2519 V_VT(&va) = VT_R8 | VT_BYREF;
2521 V_UNION(&va,pdblVal) = &d;
2522 ok(S_OK == VariantCopy( &vb, &va ), XOK);
2523 ok(*(V_R8REF(&vb)) == 123.123,"should be 123.123");
2525 V_VT(&va) = VT_R8 | VT_BYREF;
2527 V_UNION(&va,pdblVal) = &d;
2528 ok(S_OK == VariantCopyInd( &vb, &va ), XOK);
2529 ok(V_R8(&vb) == 111.2,"should be 111.2");
2531 V_VT(&va) = VT_R8 | VT_BYREF;
2533 V_UNION(&va,pdblVal) = &d;
2534 ok(S_OK == VariantChangeTypeEx( &va, &va, 0, 0, VT_I2 ), XOK);
2535 ok(V_VT(&va) == VT_I2,"should be type VT_I2");
2538 V_UNION(&va,intVal) = 4;
2539 ok(S_OK == VariantChangeTypeEx(&vb, &va, 0, 0, VT_BSTR ), XOK);
2540 ok(!strcmp(WtoA(V_BSTR(&vb)),"\"4\""),"should be 4");
2542 V_VT(&va) = VT_DATE;
2543 V_UNION(&va,date) = 34465.332431;
2544 ok(S_OK == VariantChangeTypeEx(&vb, &va, 0, 0, VT_BSTR ), XOK);
2546 ok(!strcmp(WtoA(V_BSTR(&vb)),"\"5/11/94 7:58:42 AM\""),"should be 5/11/94 7:58:42 AM");
2550 V_VT(&va) = VT_BSTR;
2551 V_UNION(&va,bstrVal) = bstr;
2552 ok(S_OK == VariantChangeTypeEx(&vb, &va, 0, 0, VT_R8 ), XOK);
2553 ok(V_R8(&vb) == -0.490000,"should be -0.49");
2555 V_VT(&vc) = VT_BSTR | VT_BYREF;
2556 V_UNION(&vc,pbstrVal) = &bstr;
2557 V_VT(&vb) = VT_VARIANT | VT_BYREF;
2558 V_UNION(&vb,pvarVal) = &vc;
2559 V_VT(&va) = VT_VARIANT | VT_BYREF;
2560 V_UNION(&va,pvarVal) = &vb;
2561 ok(E_INVALIDARG == VariantCopyInd( &vd, &va ), "expect E_INVALIDARG");
2563 /* test what happens when bad vartypes are passed in */
2564 trace( "-------------- Testing different VARTYPES ----------------\n" );
2567 for( i=0; i<sizeof(vartypes)/sizeof(vartypes[0]); i++ )
2569 /* Trying to use variants that are set to be BSTR but
2570 * do not contain a valid pointer makes the program crash
2571 * in Windows so we will skip those. We do not need them
2572 * anyway to illustrate the behavior.
2574 V_VT(&va) = vartypes[i].ind;
2576 V_UNION(&va,dblVal) = d;
2577 res = VariantCopyInd( &vb, &va );
2578 sprintf(msg,"vt %d, return value %lx, expected was %lx",vartypes[i].ind,res,vartypes[i].vcind1);
2579 ok(vartypes[i].vcind1 == res, msg);
2580 V_VT(&va) = vartypes[i].ind | VT_BYREF;
2582 V_UNION(&va,pdblVal) = &d;
2583 res = VariantCopyInd( &vb, &va );
2584 sprintf(msg,"vt %d, return value %lx, expected was %lx",vartypes[i].ind,res,vartypes[i].vcind2);
2585 ok(vartypes[i].vcind2 == res, msg);
2588 V_UNION(&va,dblVal) = d;
2589 res = VariantChangeTypeEx( &vb, &va, 0, 0, i );
2590 sprintf(msg,"vt %d, return value %lx, expected was %lx",vartypes[i].ind,res,vartypes[i].vcex1);
2591 ok(vartypes[i].vcex1 == res, msg);
2594 V_UNION(&va,dblVal) = d;
2595 res = VariantChangeTypeEx( &vb, &va, 0, 0, i | VT_BYREF );
2596 sprintf(msg,"vt %d, return value %lx, expected was %lx",vartypes[i].ind,res,vartypes[i].vcex1);
2597 ok(vartypes[i].vcex2 == res, msg);
2601 V_UNION(&va,dblVal) = d;
2602 ok(DISP_E_BADVARTYPE == VariantClear( &va ), "should give DISP_E_BADVARTYPE");
2605 VariantClear( &va );
2606 VariantClear( &vb );
2607 VariantClear( &vc );
2608 VariantClear( &vd );
2609 VariantClear( &ve );
2610 /* There is alot of memory leaks but this is simply a test program.