7#include <windows.foundation.h>
12#include "base/stl_util.h"
16#include "testing/gtest/include/gtest/gtest.h"
23TEST(VariantVectorTest, InitiallyEmpty) {
25 EXPECT_EQ(vector.
Type(), VT_EMPTY);
26 EXPECT_EQ(vector.
Size(), 0
U);
30TEST(VariantVectorTest, MoveConstructor) {
32 Microsoft::WRL::ComPtr<IDispatch> dispatch =
33 Microsoft::WRL::Make<DispatchStub>();
34 vector1.
Insert<VT_DISPATCH>(dispatch.Get());
35 EXPECT_EQ(vector1.
Type(), VT_DISPATCH);
36 EXPECT_EQ(vector1.
Size(), 1U);
39 EXPECT_EQ(vector1.
Type(), VT_EMPTY);
40 EXPECT_EQ(vector1.
Size(), 0
U);
41 EXPECT_EQ(vector2.
Type(), VT_DISPATCH);
42 EXPECT_EQ(vector2.
Size(), 1U);
44 EXPECT_EQ(dispatch.Reset(), 1U);
47TEST(VariantVectorTest, MoveAssignOperator) {
49 Microsoft::WRL::ComPtr<IDispatch> dispatch1 =
50 Microsoft::WRL::Make<DispatchStub>();
51 Microsoft::WRL::ComPtr<IDispatch> dispatch2 =
52 Microsoft::WRL::Make<DispatchStub>();
53 vector1.
Insert<VT_DISPATCH>(dispatch1.Get());
54 vector2.
Insert<VT_UNKNOWN>(dispatch2.Get());
55 EXPECT_EQ(vector1.
Type(), VT_DISPATCH);
56 EXPECT_EQ(vector1.
Size(), 1U);
57 EXPECT_EQ(vector2.
Type(), VT_UNKNOWN);
58 EXPECT_EQ(vector2.
Size(), 1U);
59 vector1 = std::move(vector2);
60 EXPECT_EQ(vector1.
Type(), VT_UNKNOWN);
61 EXPECT_EQ(vector1.
Size(), 1U);
62 EXPECT_EQ(vector2.
Type(), VT_EMPTY);
63 EXPECT_EQ(vector2.
Size(), 0
U);
65 EXPECT_EQ(dispatch1.Reset(), 0
U);
67 EXPECT_EQ(dispatch2.Reset(), 1U);
74TEST(VariantVectorTest, Insert) {
77 EXPECT_EQ(vector.
Type(), VT_I4);
83 EXPECT_EQ(vector.
Type(), VT_I4);
84 EXPECT_EQ(vector.
Size(), 1U);
85 EXPECT_FALSE(vector.
Empty());
88TEST(VariantVectorTest, InsertCanUpcastDispatchToUnknown) {
89 Microsoft::WRL::ComPtr<IDispatch> dispatch =
90 Microsoft::WRL::Make<DispatchStub>();
91 Microsoft::WRL::ComPtr<IDispatch> unknown;
92 dispatch.CopyTo(&unknown);
95 vector.
Insert<VT_UNKNOWN>(unknown.Get());
96 vector.
Insert<VT_UNKNOWN>(dispatch.Get());
97 vector.
Insert<VT_DISPATCH>(dispatch.Get());
98 EXPECT_EQ(vector.
Type(), VT_UNKNOWN);
99 EXPECT_EQ(vector.
Size(), 3U);
102TEST(VariantVectorTest, InsertCannotDowncastUnknownToDispatch) {
103 Microsoft::WRL::ComPtr<IDispatch> dispatch =
104 Microsoft::WRL::Make<DispatchStub>();
105 Microsoft::WRL::ComPtr<IDispatch> unknown;
106 dispatch.CopyTo(&unknown);
109 vector.
Insert<VT_DISPATCH>(dispatch.Get());
115 EXPECT_EQ(vector.
Type(), VT_DISPATCH);
116 EXPECT_EQ(vector.
Size(), 1U);
121 EXPECT_EQ(vector.
Type(), VT_EMPTY);
122 EXPECT_EQ(vector.
Size(), 0
U);
123 vector.
Insert<VT_I4>(123);
124 vector.
Insert<VT_I4>(456);
125 EXPECT_EQ(vector.
Type(), VT_I4);
126 EXPECT_EQ(vector.
Size(), 2U);
128 EXPECT_EQ(vector.
Type(), VT_EMPTY);
129 EXPECT_EQ(vector.
Size(), 0
U);
132TEST(VariantVectorTest, ResetWithManagedContents) {
135 Microsoft::WRL::ComPtr<IUnknown> unknown1 =
136 Microsoft::WRL::Make<DispatchStub>();
137 Microsoft::WRL::ComPtr<IUnknown> unknown2;
138 unknown1.CopyTo(&unknown2);
139 vector.
Insert<VT_UNKNOWN>(unknown1.Get());
140 EXPECT_EQ(vector.
Type(), VT_UNKNOWN);
141 EXPECT_EQ(vector.
Size(), 1U);
144 EXPECT_EQ(unknown2.Reset(), 2U);
147 EXPECT_EQ(vector.
Type(), VT_EMPTY);
148 EXPECT_EQ(vector.
Size(), 0
U);
150 EXPECT_EQ(unknown1.Reset(), 0
U);
153TEST(VariantVectorTest, ScopeWithManagedContents) {
154 Microsoft::WRL::ComPtr<IUnknown> unknown1 =
155 Microsoft::WRL::Make<DispatchStub>();
158 vector.
Insert<VT_UNKNOWN>(unknown1.Get());
159 EXPECT_EQ(vector.
Type(), VT_UNKNOWN);
160 EXPECT_EQ(vector.
Size(), 1U);
162 Microsoft::WRL::ComPtr<IUnknown> unknown2;
163 unknown1.CopyTo(&unknown2);
166 EXPECT_EQ(unknown2.Reset(), 2U);
170 EXPECT_EQ(unknown1.Reset(), 0
U);
173TEST(VariantVectorTest, ReleaseAsScalarVariantEmpty) {
176 EXPECT_EQ(variant.
type(), VT_EMPTY);
179TEST(VariantVectorTest, ReleaseAsScalarVariantSingleBool) {
183 expected_variant.
Set(
true);
184 vector.
Insert<VT_BOOL>(
true);
185 EXPECT_EQ(vector.
Type(), expected_variant.
type());
186 EXPECT_EQ(vector.
Size(), 1U);
189 EXPECT_EQ(vector.
Type(), VT_EMPTY);
190 EXPECT_EQ(vector.
Size(), 0
U);
191 EXPECT_EQ(variant.
Compare(expected_variant), 0);
194TEST(VariantVectorTest, ReleaseAsScalarVariantSingleI1) {
198 expected_variant.
Set((int8_t)34);
200 EXPECT_EQ(vector.
Type(), expected_variant.
type());
201 EXPECT_EQ(vector.
Size(), 1U);
204 EXPECT_EQ(vector.
Type(), VT_EMPTY);
205 EXPECT_EQ(vector.
Size(), 0
U);
206 EXPECT_EQ(variant.
Compare(expected_variant), 0);
209TEST(VariantVectorTest, ReleaseAsScalarVariantSingleUI1) {
213 expected_variant.
Set((uint8_t)35U);
214 vector.
Insert<VT_UI1>(35U);
215 EXPECT_EQ(vector.
Type(), expected_variant.
type());
216 EXPECT_EQ(vector.
Size(), 1U);
219 EXPECT_EQ(vector.
Type(), VT_EMPTY);
220 EXPECT_EQ(vector.
Size(), 0
U);
221 EXPECT_EQ(variant.
Compare(expected_variant), 0);
224TEST(VariantVectorTest, ReleaseAsScalarVariantSingleI2) {
228 expected_variant.
Set((int16_t)8738);
229 vector.
Insert<VT_I2>(8738);
230 EXPECT_EQ(vector.
Type(), expected_variant.
type());
231 EXPECT_EQ(vector.
Size(), 1U);
234 EXPECT_EQ(vector.
Type(), VT_EMPTY);
235 EXPECT_EQ(vector.
Size(), 0
U);
236 EXPECT_EQ(variant.
Compare(expected_variant), 0);
239TEST(VariantVectorTest, ReleaseAsScalarVariantSingleUI2) {
243 expected_variant.
Set((uint16_t)8739U);
244 vector.
Insert<VT_UI2>(8739U);
245 EXPECT_EQ(vector.
Type(), expected_variant.
type());
246 EXPECT_EQ(vector.
Size(), 1U);
249 EXPECT_EQ(vector.
Type(), VT_EMPTY);
250 EXPECT_EQ(vector.
Size(), 0
U);
251 EXPECT_EQ(variant.
Compare(expected_variant), 0);
254TEST(VariantVectorTest, ReleaseAsScalarVariantSingleI4) {
258 expected_variant.
Set((int32_t)572662306);
259 vector.
Insert<VT_I4>(572662306);
260 EXPECT_EQ(vector.
Type(), expected_variant.
type());
261 EXPECT_EQ(vector.
Size(), 1U);
264 EXPECT_EQ(vector.
Type(), VT_EMPTY);
265 EXPECT_EQ(vector.
Size(), 0
U);
266 EXPECT_EQ(variant.
Compare(expected_variant), 0);
269TEST(VariantVectorTest, ReleaseAsScalarVariantSingleUI4) {
273 expected_variant.
Set((uint32_t)572662307U);
274 vector.
Insert<VT_UI4>(572662307U);
275 EXPECT_EQ(vector.
Type(), expected_variant.
type());
276 EXPECT_EQ(vector.
Size(), 1U);
279 EXPECT_EQ(vector.
Type(), VT_EMPTY);
280 EXPECT_EQ(vector.
Size(), 0
U);
281 EXPECT_EQ(variant.
Compare(expected_variant), 0);
284TEST(VariantVectorTest, ReleaseAsScalarVariantSingleI8) {
288 expected_variant.
Set((int64_t)2459565876494606882);
289 vector.
Insert<VT_I8>(2459565876494606882);
290 EXPECT_EQ(vector.
Type(), expected_variant.
type());
291 EXPECT_EQ(vector.
Size(), 1U);
294 EXPECT_EQ(vector.
Type(), VT_EMPTY);
295 EXPECT_EQ(vector.
Size(), 0
U);
296 EXPECT_EQ(variant.
Compare(expected_variant), 0);
299TEST(VariantVectorTest, ReleaseAsScalarVariantSingleUI8) {
303 expected_variant.
Set((uint64_t)2459565876494606883U);
304 vector.
Insert<VT_UI8>(2459565876494606883U);
305 EXPECT_EQ(vector.
Type(), expected_variant.
type());
306 EXPECT_EQ(vector.
Size(), 1U);
309 EXPECT_EQ(vector.
Type(), VT_EMPTY);
310 EXPECT_EQ(vector.
Size(), 0
U);
311 EXPECT_EQ(variant.
Compare(expected_variant), 0);
314TEST(VariantVectorTest, ReleaseAsScalarVariantSingleR4) {
318 expected_variant.
Set(3.14159f);
319 vector.
Insert<VT_R4>(3.14159f);
320 EXPECT_EQ(vector.
Type(), expected_variant.
type());
321 EXPECT_EQ(vector.
Size(), 1U);
324 EXPECT_EQ(vector.
Type(), VT_EMPTY);
325 EXPECT_EQ(vector.
Size(), 0
U);
326 EXPECT_EQ(variant.
Compare(expected_variant), 0);
329TEST(VariantVectorTest, ReleaseAsScalarVariantSingleR8) {
333 expected_variant.
Set(6.28318);
334 vector.
Insert<VT_R8>(6.28318);
335 EXPECT_EQ(vector.
Type(), expected_variant.
type());
336 EXPECT_EQ(vector.
Size(), 1U);
339 EXPECT_EQ(vector.
Type(), VT_EMPTY);
340 EXPECT_EQ(vector.
Size(), 0
U);
341 EXPECT_EQ(variant.
Compare(expected_variant), 0);
344TEST(VariantVectorTest, ReleaseAsScalarVariantSingleDate) {
349 ::GetSystemTime(&sys_time);
351 ::SystemTimeToVariantTime(&sys_time, &date);
352 expected_variant.
SetDate(date);
353 vector.
Insert<VT_DATE>(date);
354 EXPECT_EQ(vector.
Type(), expected_variant.
type());
355 EXPECT_EQ(vector.
Size(), 1U);
358 EXPECT_EQ(vector.
Type(), VT_EMPTY);
359 EXPECT_EQ(vector.
Size(), 0
U);
360 EXPECT_EQ(variant.
Compare(expected_variant), 0);
363TEST(VariantVectorTest, ReleaseAsScalarVariantSingleBstr) {
367 wchar_t test_string[] =
L"Test string for BSTRs.";
368 expected_variant.
Set(test_string);
369 vector.
Insert<VT_BSTR>(test_string);
370 EXPECT_EQ(vector.
Type(), expected_variant.
type());
371 EXPECT_EQ(vector.
Size(), 1U);
374 EXPECT_EQ(vector.
Type(), VT_EMPTY);
375 EXPECT_EQ(vector.
Size(), 0
U);
376 EXPECT_EQ(variant.
Compare(expected_variant), 0);
379TEST(VariantVectorTest, ReleaseAsScalarVariantSingleUnknown) {
383 Microsoft::WRL::ComPtr<IUnknown> unknown =
384 Microsoft::WRL::Make<DispatchStub>();
385 expected_variant.
Set(unknown.Get());
386 vector.
Insert<VT_UNKNOWN>(unknown.Get());
387 EXPECT_EQ(vector.
Type(), expected_variant.
type());
388 EXPECT_EQ(vector.
Size(), 1U);
391 EXPECT_EQ(vector.
Type(), VT_EMPTY);
392 EXPECT_EQ(vector.
Size(), 0
U);
393 EXPECT_EQ(variant.
Compare(expected_variant), 0);
396TEST(VariantVectorTest, ReleaseAsScalarVariantSingleDispatch) {
400 Microsoft::WRL::ComPtr<IDispatch> dispatch =
401 Microsoft::WRL::Make<DispatchStub>();
402 expected_variant.
Set(dispatch.Get());
403 vector.
Insert<VT_DISPATCH>(dispatch.Get());
404 EXPECT_EQ(vector.
Type(), expected_variant.
type());
405 EXPECT_EQ(vector.
Size(), 1U);
408 EXPECT_EQ(vector.
Type(), VT_EMPTY);
409 EXPECT_EQ(vector.
Size(), 0
U);
410 EXPECT_EQ(variant.
Compare(expected_variant), 0);
413TEST(VariantVectorTest, ReleaseAsScalarVariantMultipleBool) {
414 constexpr VARTYPE kVariantType = VT_BOOL;
418 vector.
Insert<kVariantType>(
true);
419 vector.
Insert<kVariantType>(
false);
420 EXPECT_EQ(vector.
Type(), kVariantType);
421 EXPECT_EQ(vector.
Size(), 2U);
425TEST(VariantVectorTest, ReleaseAsScalarVariantMultipleI1) {
426 constexpr VARTYPE kVariantType = VT_I1;
430 vector.
Insert<kVariantType>(34);
431 vector.
Insert<kVariantType>(52);
432 EXPECT_EQ(vector.
Type(), kVariantType);
433 EXPECT_EQ(vector.
Size(), 2U);
437TEST(VariantVectorTest, ReleaseAsScalarVariantMultipleUI1) {
438 constexpr VARTYPE kVariantType = VT_UI1;
442 vector.
Insert<kVariantType>(34U);
443 vector.
Insert<kVariantType>(52U);
444 EXPECT_EQ(vector.
Type(), kVariantType);
445 EXPECT_EQ(vector.
Size(), 2U);
449TEST(VariantVectorTest, ReleaseAsScalarVariantMultipleI2) {
450 constexpr VARTYPE kVariantType = VT_I2;
454 vector.
Insert<kVariantType>(8738);
455 vector.
Insert<kVariantType>(8758);
456 EXPECT_EQ(vector.
Type(), kVariantType);
457 EXPECT_EQ(vector.
Size(), 2U);
461TEST(VariantVectorTest, ReleaseAsScalarVariantMultipleUI2) {
462 constexpr VARTYPE kVariantType = VT_UI2;
466 vector.
Insert<kVariantType>(8739U);
467 vector.
Insert<kVariantType>(8759U);
468 EXPECT_EQ(vector.
Type(), kVariantType);
469 EXPECT_EQ(vector.
Size(), 2U);
473TEST(VariantVectorTest, ReleaseAsScalarVariantMultipleI4) {
474 constexpr VARTYPE kVariantType = VT_I4;
478 vector.
Insert<kVariantType>(572662306);
479 vector.
Insert<kVariantType>(572662307);
480 EXPECT_EQ(vector.
Type(), kVariantType);
481 EXPECT_EQ(vector.
Size(), 2U);
485TEST(VariantVectorTest, ReleaseAsScalarVariantMultipleUI4) {
486 constexpr VARTYPE kVariantType = VT_UI4;
490 vector.
Insert<kVariantType>(578662306U);
491 vector.
Insert<kVariantType>(578662307U);
492 EXPECT_EQ(vector.
Type(), kVariantType);
493 EXPECT_EQ(vector.
Size(), 2U);
497TEST(VariantVectorTest, ReleaseAsScalarVariantMultipleI8) {
498 constexpr VARTYPE kVariantType = VT_I8;
502 vector.
Insert<kVariantType>(2459565876494606882);
503 vector.
Insert<kVariantType>(2459565876494606883);
504 EXPECT_EQ(vector.
Type(), kVariantType);
505 EXPECT_EQ(vector.
Size(), 2U);
509TEST(VariantVectorTest, ReleaseAsScalarVariantMultipleUI8) {
510 constexpr VARTYPE kVariantType = VT_UI8;
514 vector.
Insert<kVariantType>(2459565876494606883U);
515 vector.
Insert<kVariantType>(2459565876494606884U);
516 EXPECT_EQ(vector.
Type(), kVariantType);
517 EXPECT_EQ(vector.
Size(), 2U);
521TEST(VariantVectorTest, ReleaseAsScalarVariantMultipleR4) {
522 constexpr VARTYPE kVariantType = VT_R4;
526 vector.
Insert<kVariantType>(3.14159f);
527 vector.
Insert<kVariantType>(6.28318f);
528 EXPECT_EQ(vector.
Type(), kVariantType);
529 EXPECT_EQ(vector.
Size(), 2U);
533TEST(VariantVectorTest, ReleaseAsScalarVariantMultipleR8) {
534 constexpr VARTYPE kVariantType = VT_R8;
538 vector.
Insert<kVariantType>(6.28318);
539 vector.
Insert<kVariantType>(3.14159);
540 EXPECT_EQ(vector.
Type(), kVariantType);
541 EXPECT_EQ(vector.
Size(), 2U);
545TEST(VariantVectorTest, ReleaseAsScalarVariantMultipleDate) {
546 constexpr VARTYPE kVariantType = VT_DATE;
551 ::GetSystemTime(&sys_time);
553 ::SystemTimeToVariantTime(&sys_time, &date);
555 vector.
Insert<kVariantType>(date);
556 vector.
Insert<kVariantType>(date);
557 EXPECT_EQ(vector.
Type(), kVariantType);
558 EXPECT_EQ(vector.
Size(), 2U);
562TEST(VariantVectorTest, ReleaseAsScalarVariantMultipleBstr) {
563 constexpr VARTYPE kVariantType = VT_BSTR;
567 wchar_t some_text[] =
L"some text";
568 wchar_t more_text[] =
L"more text";
569 vector.
Insert<kVariantType>(some_text);
570 vector.
Insert<kVariantType>(more_text);
571 EXPECT_EQ(vector.
Type(), kVariantType);
572 EXPECT_EQ(vector.
Size(), 2U);
576TEST(VariantVectorTest, ReleaseAsScalarVariantMultipleUnknown) {
577 constexpr VARTYPE kVariantType = VT_UNKNOWN;
581 Microsoft::WRL::ComPtr<IUnknown> unknown1 =
582 Microsoft::WRL::Make<DispatchStub>();
583 Microsoft::WRL::ComPtr<IUnknown> unknown2 =
584 Microsoft::WRL::Make<DispatchStub>();
586 vector.
Insert<kVariantType>(unknown1.Get());
587 vector.
Insert<kVariantType>(unknown2.Get());
588 EXPECT_EQ(vector.
Type(), kVariantType);
589 EXPECT_EQ(vector.
Size(), 2U);
593TEST(VariantVectorTest, ReleaseAsScalarVariantMultipleDispatch) {
594 constexpr VARTYPE kVariantType = VT_DISPATCH;
598 Microsoft::WRL::ComPtr<IDispatch> dispatch1 =
599 Microsoft::WRL::Make<DispatchStub>();
600 Microsoft::WRL::ComPtr<IDispatch> dispatch2 =
601 Microsoft::WRL::Make<DispatchStub>();
603 vector.
Insert<kVariantType>(dispatch1.Get());
604 vector.
Insert<kVariantType>(dispatch2.Get());
605 EXPECT_EQ(vector.
Type(), kVariantType);
606 EXPECT_EQ(vector.
Size(), 2U);
610TEST(VariantVectorTest, ReleaseAsSafearrayVariantEmpty) {
613 EXPECT_EQ(variant.
type(), VT_EMPTY);
616TEST(VariantVectorTest, ReleaseAsSafearrayVariantSingleBool) {
617 constexpr VARTYPE kVariantType = VT_BOOL;
620 vector.
Insert<kVariantType>(
true);
621 EXPECT_EQ(vector.
Type(), kVariantType);
622 EXPECT_EQ(vector.
Size(), 1U);
625 EXPECT_EQ(vector.
Type(), VT_EMPTY);
626 EXPECT_EQ(vector.
Size(), 0
U);
627 EXPECT_EQ(variant.
type(), VT_ARRAY | kVariantType);
630 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
632 ASSERT_TRUE(lock_scope.has_value());
633 ASSERT_EQ(lock_scope->size(), 1U);
634 EXPECT_EQ(lock_scope->at(0), VARIANT_TRUE);
638TEST(VariantVectorTest, ReleaseAsSafearrayVariantSingleI1) {
639 constexpr VARTYPE kVariantType = VT_I1;
642 vector.
Insert<kVariantType>(34);
643 EXPECT_EQ(vector.
Type(), kVariantType);
644 EXPECT_EQ(vector.
Size(), 1U);
647 EXPECT_EQ(vector.
Type(), VT_EMPTY);
648 EXPECT_EQ(vector.
Size(), 0
U);
649 EXPECT_EQ(variant.
type(), VT_ARRAY | kVariantType);
652 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
654 ASSERT_TRUE(lock_scope.has_value());
655 ASSERT_EQ(lock_scope->size(), 1U);
656 EXPECT_EQ(lock_scope->at(0), 34);
660TEST(VariantVectorTest, ReleaseAsSafearrayVariantSingleUI1) {
661 constexpr VARTYPE kVariantType = VT_UI1;
664 vector.
Insert<kVariantType>(34U);
665 EXPECT_EQ(vector.
Type(), kVariantType);
666 EXPECT_EQ(vector.
Size(), 1U);
669 EXPECT_EQ(vector.
Type(), VT_EMPTY);
670 EXPECT_EQ(vector.
Size(), 0
U);
671 EXPECT_EQ(variant.
type(), VT_ARRAY | kVariantType);
674 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
676 ASSERT_TRUE(lock_scope.has_value());
677 ASSERT_EQ(lock_scope->size(), 1U);
678 EXPECT_EQ(lock_scope->at(0), 34U);
682TEST(VariantVectorTest, ReleaseAsSafearrayVariantSingleI2) {
683 constexpr VARTYPE kVariantType = VT_I2;
686 vector.
Insert<kVariantType>(8738);
687 EXPECT_EQ(vector.
Type(), kVariantType);
688 EXPECT_EQ(vector.
Size(), 1U);
691 EXPECT_EQ(vector.
Type(), VT_EMPTY);
692 EXPECT_EQ(vector.
Size(), 0
U);
693 EXPECT_EQ(variant.
type(), VT_ARRAY | kVariantType);
696 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
698 ASSERT_TRUE(lock_scope.has_value());
699 ASSERT_EQ(lock_scope->size(), 1U);
700 EXPECT_EQ(lock_scope->at(0), 8738);
704TEST(VariantVectorTest, ReleaseAsSafearrayVariantSingleUI2) {
705 constexpr VARTYPE kVariantType = VT_UI2;
708 vector.
Insert<kVariantType>(8739U);
709 EXPECT_EQ(vector.
Type(), kVariantType);
710 EXPECT_EQ(vector.
Size(), 1U);
713 EXPECT_EQ(vector.
Type(), VT_EMPTY);
714 EXPECT_EQ(vector.
Size(), 0
U);
715 EXPECT_EQ(variant.
type(), VT_ARRAY | kVariantType);
718 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
720 ASSERT_TRUE(lock_scope.has_value());
721 ASSERT_EQ(lock_scope->size(), 1U);
722 EXPECT_EQ(lock_scope->at(0), 8739U);
726TEST(VariantVectorTest, ReleaseAsSafearrayVariantSingleI4) {
727 constexpr VARTYPE kVariantType = VT_I4;
730 vector.
Insert<kVariantType>(572662306);
731 EXPECT_EQ(vector.
Type(), kVariantType);
732 EXPECT_EQ(vector.
Size(), 1U);
735 EXPECT_EQ(vector.
Type(), VT_EMPTY);
736 EXPECT_EQ(vector.
Size(), 0
U);
737 EXPECT_EQ(variant.
type(), VT_ARRAY | kVariantType);
740 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
742 ASSERT_TRUE(lock_scope.has_value());
743 ASSERT_EQ(lock_scope->size(), 1U);
744 EXPECT_EQ(lock_scope->at(0), 572662306);
748TEST(VariantVectorTest, ReleaseAsSafearrayVariantSingleUI4) {
749 constexpr VARTYPE kVariantType = VT_UI4;
752 vector.
Insert<kVariantType>(578662306U);
753 EXPECT_EQ(vector.
Type(), kVariantType);
754 EXPECT_EQ(vector.
Size(), 1U);
757 EXPECT_EQ(vector.
Type(), VT_EMPTY);
758 EXPECT_EQ(vector.
Size(), 0
U);
759 EXPECT_EQ(variant.
type(), VT_ARRAY | kVariantType);
762 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
764 ASSERT_TRUE(lock_scope.has_value());
765 ASSERT_EQ(lock_scope->size(), 1U);
766 EXPECT_EQ(lock_scope->at(0), 578662306U);
770TEST(VariantVectorTest, ReleaseAsSafearrayVariantSingleI8) {
771 constexpr VARTYPE kVariantType = VT_I8;
774 vector.
Insert<kVariantType>(2459565876494606882);
775 EXPECT_EQ(vector.
Type(), kVariantType);
776 EXPECT_EQ(vector.
Size(), 1U);
779 EXPECT_EQ(vector.
Type(), VT_EMPTY);
780 EXPECT_EQ(vector.
Size(), 0
U);
781 EXPECT_EQ(variant.
type(), VT_ARRAY | kVariantType);
784 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
786 ASSERT_TRUE(lock_scope.has_value());
787 ASSERT_EQ(lock_scope->size(), 1U);
788 EXPECT_EQ(lock_scope->at(0), 2459565876494606882);
792TEST(VariantVectorTest, ReleaseAsSafearrayVariantSingleUI8) {
793 constexpr VARTYPE kVariantType = VT_UI8;
796 vector.
Insert<kVariantType>(2459565876494606883U);
797 EXPECT_EQ(vector.
Type(), kVariantType);
798 EXPECT_EQ(vector.
Size(), 1U);
801 EXPECT_EQ(vector.
Type(), VT_EMPTY);
802 EXPECT_EQ(vector.
Size(), 0
U);
803 EXPECT_EQ(variant.
type(), VT_ARRAY | kVariantType);
806 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
808 ASSERT_TRUE(lock_scope.has_value());
809 ASSERT_EQ(lock_scope->size(), 1U);
810 EXPECT_EQ(lock_scope->at(0), 2459565876494606883U);
814TEST(VariantVectorTest, ReleaseAsSafearrayVariantSingleR4) {
815 constexpr VARTYPE kVariantType = VT_R4;
818 vector.
Insert<kVariantType>(3.14159f);
819 EXPECT_EQ(vector.
Type(), kVariantType);
820 EXPECT_EQ(vector.
Size(), 1U);
823 EXPECT_EQ(vector.
Type(), VT_EMPTY);
824 EXPECT_EQ(vector.
Size(), 0
U);
825 EXPECT_EQ(variant.
type(), VT_ARRAY | kVariantType);
828 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
830 ASSERT_TRUE(lock_scope.has_value());
831 ASSERT_EQ(lock_scope->size(), 1U);
832 EXPECT_EQ(lock_scope->at(0), 3.14159f);
836TEST(VariantVectorTest, ReleaseAsSafearrayVariantSingleR8) {
837 constexpr VARTYPE kVariantType = VT_R8;
840 vector.
Insert<kVariantType>(6.28318);
841 EXPECT_EQ(vector.
Type(), kVariantType);
842 EXPECT_EQ(vector.
Size(), 1U);
845 EXPECT_EQ(vector.
Type(), VT_EMPTY);
846 EXPECT_EQ(vector.
Size(), 0
U);
847 EXPECT_EQ(variant.
type(), VT_ARRAY | kVariantType);
850 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
852 ASSERT_TRUE(lock_scope.has_value());
853 ASSERT_EQ(lock_scope->size(), 1U);
854 EXPECT_EQ(lock_scope->at(0), 6.28318);
858TEST(VariantVectorTest, ReleaseAsSafearrayVariantSingleDate) {
859 constexpr VARTYPE kVariantType = VT_DATE;
863 ::GetSystemTime(&sys_time);
865 ::SystemTimeToVariantTime(&sys_time, &date);
867 vector.
Insert<kVariantType>(date);
868 EXPECT_EQ(vector.
Type(), kVariantType);
869 EXPECT_EQ(vector.
Size(), 1U);
872 EXPECT_EQ(vector.
Type(), VT_EMPTY);
873 EXPECT_EQ(vector.
Size(), 0
U);
874 EXPECT_EQ(variant.
type(), VT_ARRAY | kVariantType);
877 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
879 ASSERT_TRUE(lock_scope.has_value());
880 ASSERT_EQ(lock_scope->size(), 1U);
881 EXPECT_EQ(lock_scope->at(0), date);
885TEST(VariantVectorTest, ReleaseAsSafearrayVariantSingleBstr) {
886 constexpr VARTYPE kVariantType = VT_BSTR;
889 wchar_t some_text[] =
L"some text";
890 vector.
Insert<kVariantType>(some_text);
891 EXPECT_EQ(vector.
Type(), kVariantType);
892 EXPECT_EQ(vector.
Size(), 1U);
895 EXPECT_EQ(vector.
Type(), VT_EMPTY);
896 EXPECT_EQ(vector.
Size(), 0
U);
897 EXPECT_EQ(variant.
type(), VT_ARRAY | kVariantType);
900 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
902 ASSERT_TRUE(lock_scope.has_value());
903 ASSERT_EQ(lock_scope->size(), 1U);
904 EXPECT_STREQ(lock_scope->at(0), some_text);
908TEST(VariantVectorTest, ReleaseAsSafearrayVariantSingleUnknown) {
909 constexpr VARTYPE kVariantType = VT_UNKNOWN;
912 Microsoft::WRL::ComPtr<IUnknown> unknown =
913 Microsoft::WRL::Make<DispatchStub>();
915 vector.
Insert<kVariantType>(unknown.Get());
916 EXPECT_EQ(vector.
Type(), kVariantType);
917 EXPECT_EQ(vector.
Size(), 1U);
920 EXPECT_EQ(vector.
Type(), VT_EMPTY);
921 EXPECT_EQ(vector.
Size(), 0
U);
922 EXPECT_EQ(variant.
type(), VT_ARRAY | kVariantType);
925 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
927 ASSERT_TRUE(lock_scope.has_value());
928 ASSERT_EQ(lock_scope->size(), 1U);
929 EXPECT_EQ(lock_scope->at(0), unknown.Get());
933TEST(VariantVectorTest, ReleaseAsSafearrayVariantSingleDispatch) {
934 constexpr VARTYPE kVariantType = VT_DISPATCH;
937 Microsoft::WRL::ComPtr<IDispatch> dispatch =
938 Microsoft::WRL::Make<DispatchStub>();
940 vector.
Insert<kVariantType>(dispatch.Get());
941 EXPECT_EQ(vector.
Type(), kVariantType);
942 EXPECT_EQ(vector.
Size(), 1U);
945 EXPECT_EQ(vector.
Type(), VT_EMPTY);
946 EXPECT_EQ(vector.
Size(), 0
U);
947 EXPECT_EQ(variant.
type(), VT_ARRAY | kVariantType);
950 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
952 ASSERT_TRUE(lock_scope.has_value());
953 ASSERT_EQ(lock_scope->size(), 1U);
954 EXPECT_EQ(lock_scope->at(0), dispatch.Get());
958TEST(VariantVectorTest, ReleaseAsSafearrayVariantMultipleBool) {
959 constexpr VARTYPE kVariantType = VT_BOOL;
962 vector.
Insert<kVariantType>(
true);
963 vector.
Insert<kVariantType>(
false);
964 vector.
Insert<kVariantType>(
true);
965 EXPECT_EQ(vector.
Type(), kVariantType);
966 EXPECT_EQ(vector.
Size(), 3U);
969 EXPECT_EQ(vector.
Type(), VT_EMPTY);
970 EXPECT_EQ(vector.
Size(), 0
U);
971 EXPECT_EQ(variant.
type(), VT_ARRAY | kVariantType);
974 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
976 ASSERT_TRUE(lock_scope.has_value());
977 ASSERT_EQ(lock_scope->size(), 3U);
978 EXPECT_EQ(lock_scope->at(0), VARIANT_TRUE);
979 EXPECT_EQ(lock_scope->at(1), VARIANT_FALSE);
980 EXPECT_EQ(lock_scope->at(2), VARIANT_TRUE);
984TEST(VariantVectorTest, ReleaseAsSafearrayVariantMultipleI1) {
985 constexpr VARTYPE kVariantType = VT_I1;
988 vector.
Insert<kVariantType>(34);
989 vector.
Insert<kVariantType>(52);
990 vector.
Insert<kVariantType>(12);
991 EXPECT_EQ(vector.
Type(), kVariantType);
992 EXPECT_EQ(vector.
Size(), 3U);
995 EXPECT_EQ(vector.
Type(), VT_EMPTY);
996 EXPECT_EQ(vector.
Size(), 0
U);
997 EXPECT_EQ(variant.
type(), VT_ARRAY | kVariantType);
1000 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
1002 ASSERT_TRUE(lock_scope.has_value());
1003 ASSERT_EQ(lock_scope->size(), 3U);
1004 EXPECT_EQ(lock_scope->at(0), 34);
1005 EXPECT_EQ(lock_scope->at(1), 52);
1006 EXPECT_EQ(lock_scope->at(2), 12);
1010TEST(VariantVectorTest, ReleaseAsSafearrayVariantMultipleUI1) {
1011 constexpr VARTYPE kVariantType = VT_UI1;
1014 vector.
Insert<kVariantType>(34U);
1015 vector.
Insert<kVariantType>(52U);
1016 vector.
Insert<kVariantType>(12U);
1017 EXPECT_EQ(vector.
Type(), kVariantType);
1018 EXPECT_EQ(vector.
Size(), 3U);
1021 EXPECT_EQ(vector.
Type(), VT_EMPTY);
1022 EXPECT_EQ(vector.
Size(), 0
U);
1023 EXPECT_EQ(variant.
type(), VT_ARRAY | kVariantType);
1026 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
1028 ASSERT_TRUE(lock_scope.has_value());
1029 ASSERT_EQ(lock_scope->size(), 3U);
1030 EXPECT_EQ(lock_scope->at(0), 34U);
1031 EXPECT_EQ(lock_scope->at(1), 52U);
1032 EXPECT_EQ(lock_scope->at(2), 12U);
1036TEST(VariantVectorTest, ReleaseAsSafearrayVariantMultipleI2) {
1037 constexpr VARTYPE kVariantType = VT_I2;
1040 vector.
Insert<kVariantType>(8738);
1041 vector.
Insert<kVariantType>(8758);
1042 vector.
Insert<kVariantType>(42);
1043 EXPECT_EQ(vector.
Type(), kVariantType);
1044 EXPECT_EQ(vector.
Size(), 3U);
1047 EXPECT_EQ(vector.
Type(), VT_EMPTY);
1048 EXPECT_EQ(vector.
Size(), 0
U);
1049 EXPECT_EQ(variant.
type(), VT_ARRAY | kVariantType);
1052 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
1054 ASSERT_TRUE(lock_scope.has_value());
1055 ASSERT_EQ(lock_scope->size(), 3U);
1056 EXPECT_EQ(lock_scope->at(0), 8738);
1057 EXPECT_EQ(lock_scope->at(1), 8758);
1058 EXPECT_EQ(lock_scope->at(2), 42);
1062TEST(VariantVectorTest, ReleaseAsSafearrayVariantMultipleUI2) {
1063 constexpr VARTYPE kVariantType = VT_UI2;
1066 vector.
Insert<kVariantType>(8739U);
1067 vector.
Insert<kVariantType>(8759U);
1068 vector.
Insert<kVariantType>(42U);
1069 EXPECT_EQ(vector.
Type(), kVariantType);
1070 EXPECT_EQ(vector.
Size(), 3U);
1073 EXPECT_EQ(vector.
Type(), VT_EMPTY);
1074 EXPECT_EQ(vector.
Size(), 0
U);
1075 EXPECT_EQ(variant.
type(), VT_ARRAY | kVariantType);
1078 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
1080 ASSERT_TRUE(lock_scope.has_value());
1081 ASSERT_EQ(lock_scope->size(), 3U);
1082 EXPECT_EQ(lock_scope->at(0), 8739U);
1083 EXPECT_EQ(lock_scope->at(1), 8759U);
1084 EXPECT_EQ(lock_scope->at(2), 42U);
1088TEST(VariantVectorTest, ReleaseAsSafearrayVariantMultipleI4) {
1089 constexpr VARTYPE kVariantType = VT_I4;
1092 vector.
Insert<kVariantType>(572662306);
1093 vector.
Insert<kVariantType>(572662307);
1094 vector.
Insert<kVariantType>(572662308);
1095 EXPECT_EQ(vector.
Type(), kVariantType);
1096 EXPECT_EQ(vector.
Size(), 3U);
1099 EXPECT_EQ(vector.
Type(), VT_EMPTY);
1100 EXPECT_EQ(vector.
Size(), 0
U);
1101 EXPECT_EQ(variant.
type(), VT_ARRAY | kVariantType);
1104 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
1106 ASSERT_TRUE(lock_scope.has_value());
1107 ASSERT_EQ(lock_scope->size(), 3U);
1108 EXPECT_EQ(lock_scope->at(0), 572662306);
1109 EXPECT_EQ(lock_scope->at(1), 572662307);
1110 EXPECT_EQ(lock_scope->at(2), 572662308);
1114TEST(VariantVectorTest, ReleaseAsSafearrayVariantMultipleUI4) {
1115 constexpr VARTYPE kVariantType = VT_UI4;
1118 vector.
Insert<kVariantType>(578662306U);
1119 vector.
Insert<kVariantType>(578662307U);
1120 vector.
Insert<kVariantType>(578662308U);
1121 EXPECT_EQ(vector.
Type(), kVariantType);
1122 EXPECT_EQ(vector.
Size(), 3U);
1125 EXPECT_EQ(vector.
Type(), VT_EMPTY);
1126 EXPECT_EQ(vector.
Size(), 0
U);
1127 EXPECT_EQ(variant.
type(), VT_ARRAY | kVariantType);
1130 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
1132 ASSERT_TRUE(lock_scope.has_value());
1133 ASSERT_EQ(lock_scope->size(), 3U);
1134 EXPECT_EQ(lock_scope->at(0), 578662306U);
1135 EXPECT_EQ(lock_scope->at(1), 578662307U);
1136 EXPECT_EQ(lock_scope->at(2), 578662308U);
1140TEST(VariantVectorTest, ReleaseAsSafearrayVariantMultipleI8) {
1141 constexpr VARTYPE kVariantType = VT_I8;
1144 vector.
Insert<kVariantType>(2459565876494606882);
1145 vector.
Insert<kVariantType>(2459565876494606883);
1146 vector.
Insert<kVariantType>(2459565876494606884);
1147 EXPECT_EQ(vector.
Type(), kVariantType);
1148 EXPECT_EQ(vector.
Size(), 3U);
1151 EXPECT_EQ(vector.
Type(), VT_EMPTY);
1152 EXPECT_EQ(vector.
Size(), 0
U);
1153 EXPECT_EQ(variant.
type(), VT_ARRAY | kVariantType);
1156 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
1158 ASSERT_TRUE(lock_scope.has_value());
1159 ASSERT_EQ(lock_scope->size(), 3U);
1160 EXPECT_EQ(lock_scope->at(0), 2459565876494606882);
1161 EXPECT_EQ(lock_scope->at(1), 2459565876494606883);
1162 EXPECT_EQ(lock_scope->at(2), 2459565876494606884);
1166TEST(VariantVectorTest, ReleaseAsSafearrayVariantMultipleUI8) {
1167 constexpr VARTYPE kVariantType = VT_UI8;
1170 vector.
Insert<kVariantType>(2459565876494606883U);
1171 vector.
Insert<kVariantType>(2459565876494606884U);
1172 vector.
Insert<kVariantType>(2459565876494606885U);
1173 EXPECT_EQ(vector.
Type(), kVariantType);
1174 EXPECT_EQ(vector.
Size(), 3U);
1177 EXPECT_EQ(vector.
Type(), VT_EMPTY);
1178 EXPECT_EQ(vector.
Size(), 0
U);
1179 EXPECT_EQ(variant.
type(), VT_ARRAY | kVariantType);
1182 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
1184 ASSERT_TRUE(lock_scope.has_value());
1185 ASSERT_EQ(lock_scope->size(), 3U);
1186 EXPECT_EQ(lock_scope->at(0), 2459565876494606883U);
1187 EXPECT_EQ(lock_scope->at(1), 2459565876494606884U);
1188 EXPECT_EQ(lock_scope->at(2), 2459565876494606885U);
1192TEST(VariantVectorTest, ReleaseAsSafearrayVariantMultipleR4) {
1193 constexpr VARTYPE kVariantType = VT_R4;
1196 vector.
Insert<kVariantType>(3.14159f);
1197 vector.
Insert<kVariantType>(6.28318f);
1198 EXPECT_EQ(vector.
Type(), kVariantType);
1199 EXPECT_EQ(vector.
Size(), 2U);
1202 EXPECT_EQ(vector.
Type(), VT_EMPTY);
1203 EXPECT_EQ(vector.
Size(), 0
U);
1204 EXPECT_EQ(variant.
type(), VT_ARRAY | kVariantType);
1207 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
1209 ASSERT_TRUE(lock_scope.has_value());
1210 ASSERT_EQ(lock_scope->size(), 2U);
1211 EXPECT_EQ(lock_scope->at(0), 3.14159f);
1212 EXPECT_EQ(lock_scope->at(1), 6.28318f);
1216TEST(VariantVectorTest, ReleaseAsSafearrayVariantMultipleR8) {
1217 constexpr VARTYPE kVariantType = VT_R8;
1220 vector.
Insert<kVariantType>(6.28318);
1221 vector.
Insert<kVariantType>(3.14159);
1222 EXPECT_EQ(vector.
Type(), kVariantType);
1223 EXPECT_EQ(vector.
Size(), 2U);
1226 EXPECT_EQ(vector.
Type(), VT_EMPTY);
1227 EXPECT_EQ(vector.
Size(), 0
U);
1228 EXPECT_EQ(variant.
type(), VT_ARRAY | kVariantType);
1231 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
1233 ASSERT_TRUE(lock_scope.has_value());
1234 ASSERT_EQ(lock_scope->size(), 2U);
1235 EXPECT_EQ(lock_scope->at(0), 6.28318);
1236 EXPECT_EQ(lock_scope->at(1), 3.14159);
1240TEST(VariantVectorTest, ReleaseAsSafearrayVariantMultipleDate) {
1241 constexpr VARTYPE kVariantType = VT_DATE;
1243 SYSTEMTIME sys_time;
1244 ::GetSystemTime(&sys_time);
1246 ::SystemTimeToVariantTime(&sys_time, &date);
1248 vector.
Insert<kVariantType>(date);
1249 vector.
Insert<kVariantType>(date);
1250 EXPECT_EQ(vector.
Type(), kVariantType);
1251 EXPECT_EQ(vector.
Size(), 2U);
1254 EXPECT_EQ(vector.
Type(), VT_EMPTY);
1255 EXPECT_EQ(vector.
Size(), 0
U);
1256 EXPECT_EQ(variant.
type(), VT_ARRAY | kVariantType);
1259 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
1261 ASSERT_TRUE(lock_scope.has_value());
1262 ASSERT_EQ(lock_scope->size(), 2U);
1263 EXPECT_EQ(lock_scope->at(0), date);
1264 EXPECT_EQ(lock_scope->at(1), date);
1268TEST(VariantVectorTest, ReleaseAsSafearrayVariantMultipleBstr) {
1269 constexpr VARTYPE kVariantType = VT_BSTR;
1271 wchar_t some_text[] =
L"some text";
1272 wchar_t more_text[] =
L"more text";
1273 vector.
Insert<kVariantType>(some_text);
1274 vector.
Insert<kVariantType>(more_text);
1275 EXPECT_EQ(vector.
Type(), kVariantType);
1276 EXPECT_EQ(vector.
Size(), 2U);
1279 EXPECT_EQ(vector.
Type(), VT_EMPTY);
1280 EXPECT_EQ(vector.
Size(), 0
U);
1281 EXPECT_EQ(variant.
type(), VT_ARRAY | kVariantType);
1284 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
1286 ASSERT_TRUE(lock_scope.has_value());
1287 ASSERT_EQ(lock_scope->size(), 2U);
1288 EXPECT_STREQ(lock_scope->at(0), some_text);
1289 EXPECT_STREQ(lock_scope->at(1), more_text);
1293TEST(VariantVectorTest, ReleaseAsSafearrayVariantMultipleUnknown) {
1294 constexpr VARTYPE kVariantType = VT_UNKNOWN;
1297 Microsoft::WRL::ComPtr<IUnknown> unknown1 =
1298 Microsoft::WRL::Make<DispatchStub>();
1299 Microsoft::WRL::ComPtr<IUnknown> unknown2 =
1300 Microsoft::WRL::Make<DispatchStub>();
1302 vector.
Insert<kVariantType>(unknown1.Get());
1303 vector.
Insert<kVariantType>(unknown2.Get());
1304 EXPECT_EQ(vector.
Type(), kVariantType);
1305 EXPECT_EQ(vector.
Size(), 2U);
1308 EXPECT_EQ(vector.
Type(), VT_EMPTY);
1309 EXPECT_EQ(vector.
Size(), 0
U);
1310 EXPECT_EQ(variant.
type(), VT_ARRAY | kVariantType);
1313 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
1315 ASSERT_TRUE(lock_scope.has_value());
1316 ASSERT_EQ(lock_scope->size(), 2U);
1317 EXPECT_EQ(lock_scope->at(0), unknown1.Get());
1318 EXPECT_EQ(lock_scope->at(1), unknown2.Get());
1322TEST(VariantVectorTest, ReleaseAsSafearrayVariantMultipleDispatch) {
1323 constexpr VARTYPE kVariantType = VT_DISPATCH;
1326 Microsoft::WRL::ComPtr<IDispatch> dispatch1 =
1327 Microsoft::WRL::Make<DispatchStub>();
1328 Microsoft::WRL::ComPtr<IDispatch> dispatch2 =
1329 Microsoft::WRL::Make<DispatchStub>();
1331 vector.
Insert<kVariantType>(dispatch1.Get());
1332 vector.
Insert<kVariantType>(dispatch2.Get());
1333 EXPECT_EQ(vector.
Type(), kVariantType);
1334 EXPECT_EQ(vector.
Size(), 2U);
1337 EXPECT_EQ(vector.
Type(), VT_EMPTY);
1338 EXPECT_EQ(vector.
Size(), 0
U);
1339 EXPECT_EQ(variant.
type(), VT_ARRAY | kVariantType);
1342 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
1344 ASSERT_TRUE(lock_scope.has_value());
1345 ASSERT_EQ(lock_scope->size(), 2U);
1346 EXPECT_EQ(lock_scope->at(0), dispatch1.Get());
1347 EXPECT_EQ(lock_scope->at(1), dispatch2.Get());
1351TEST(VariantVectorTest, CompareVariant) {
1354 EXPECT_EQ(vector.
Compare(variant), 0);
1356 vector.
Insert<VT_I4>(123);
1357 EXPECT_EQ(vector.
Type(), VT_I4);
1358 EXPECT_EQ(vector.
Size(), 1U);
1361 EXPECT_EQ(vector.
Compare(variant), 0);
1363 EXPECT_EQ(vector.
Compare(variant), 1);
1365 EXPECT_EQ(vector.
Compare(variant), -1);
1370 EXPECT_EQ(variant.
type(), VT_R8);
1371 EXPECT_LT(vector.
Type(), variant.
type());
1372 EXPECT_EQ(vector.
Compare(variant), -1);
1374 vector.
Insert<VT_I4>(456);
1375 EXPECT_EQ(vector.
Size(), 2U);
1380 EXPECT_EQ(vector.
Compare(variant), 1);
1383 EXPECT_EQ(vector.
Compare(variant), 1);
1386 EXPECT_EQ(vector.
Compare(variant), -1);
1389TEST(VariantVectorTest, CompareSafearray) {
1391 vector.
Insert<VT_I4>(123);
1392 vector.
Insert<VT_I4>(456);
1393 EXPECT_EQ(vector.
Type(), VT_I4);
1394 EXPECT_EQ(vector.
Size(), 2U);
1397 EXPECT_EQ(variant.
type(), VT_ARRAY | VT_I4);
1398 EXPECT_EQ(vector.
Type(), VT_EMPTY);
1399 EXPECT_EQ(vector.
Size(), 0
U);
1402 EXPECT_EQ(vector.
Compare(V_ARRAY(variant.
ptr())), -1);
1403 EXPECT_EQ(vector.
Compare(variant), -1);
1405 vector.
Insert<VT_I4>(123);
1406 EXPECT_EQ(vector.
Type(), VT_I4);
1407 EXPECT_EQ(vector.
Size(), 1U);
1409 EXPECT_EQ(vector.
Compare(V_ARRAY(variant.
ptr())), -1);
1410 EXPECT_EQ(vector.
Compare(variant), -1);
1412 vector.
Insert<VT_I4>(456);
1413 EXPECT_EQ(vector.
Type(), VT_I4);
1414 EXPECT_EQ(vector.
Size(), 2U);
1416 EXPECT_EQ(vector.
Compare(V_ARRAY(variant.
ptr())), 0);
1417 EXPECT_EQ(vector.
Compare(variant), 0);
1419 vector.
Insert<VT_I4>(789);
1420 EXPECT_EQ(vector.
Type(), VT_I4);
1421 EXPECT_EQ(vector.
Size(), 3U);
1424 EXPECT_EQ(vector.
Compare(V_ARRAY(variant.
ptr())), 1);
1425 EXPECT_EQ(vector.
Compare(variant), 1);
1428 vector.
Insert<VT_I4>(456);
1429 EXPECT_EQ(vector.
Type(), VT_I4);
1430 EXPECT_EQ(vector.
Size(), 1U);
1433 EXPECT_EQ(vector.
Compare(V_ARRAY(variant.
ptr())), 1);
1434 EXPECT_EQ(vector.
Compare(variant), 1);
1437 vector.
Insert<VT_R8>(0.0);
1438 vector.
Insert<VT_R8>(0.0);
1439 EXPECT_EQ(vector.
Type(), VT_R8);
1443 EXPECT_GT(VT_R8, VT_I4);
1444 EXPECT_EQ(vector.
Compare(V_ARRAY(variant.
ptr())), 1);
1445 EXPECT_EQ(vector.
Compare(variant), 1);
1448 vector.
Insert<VT_I2>(1000);
1449 vector.
Insert<VT_I2>(1000);
1450 EXPECT_EQ(vector.
Type(), VT_I2);
1454 EXPECT_LT(VT_I2, VT_I4);
1455 EXPECT_EQ(vector.
Compare(V_ARRAY(variant.
ptr())), -1);
1456 EXPECT_EQ(vector.
Compare(variant), -1);
1459TEST(VariantVectorTest, CompareVariantVector) {
1461 EXPECT_EQ(vector1.
Compare(vector2), 0);
1462 EXPECT_EQ(vector1, vector2);
1464 vector1.
Insert<VT_I4>(1);
1465 EXPECT_EQ(vector1.
Compare(vector2), 1);
1466 EXPECT_EQ(vector2.
Compare(vector1), -1);
1467 EXPECT_NE(vector1, vector2);
1469 vector2.
Insert<VT_I4>(1);
1470 EXPECT_EQ(vector1.
Compare(vector2), 0);
1471 EXPECT_EQ(vector2.
Compare(vector1), 0);
1472 EXPECT_EQ(vector1, vector2);
1474 vector1.
Insert<VT_I4>(1);
1475 EXPECT_EQ(vector1.
Compare(vector2), 1);
1476 EXPECT_EQ(vector2.
Compare(vector1), -1);
1477 EXPECT_NE(vector1, vector2);
1479 vector2.
Insert<VT_I4>(2);
1480 EXPECT_EQ(vector1.
Compare(vector2), -1);
1481 EXPECT_EQ(vector2.
Compare(vector1), 1);
1482 EXPECT_NE(vector1, vector2);
1485 vector1.
Insert<VT_I4>(10);
1487 vector2.
Insert<VT_R8>(5.0);
1491 EXPECT_LT(vector1.
Type(), vector2.
Type());
1492 EXPECT_EQ(vector1.
Compare(vector2), -1);
1493 EXPECT_EQ(vector2.
Compare(vector1), 1);
1494 EXPECT_NE(vector1, vector2);
std::optional< LockScope< ElementVartype > > CreateLockScope() const
const VARIANT * ptr() const
void Set(const wchar_t *str)
int Compare(const VARIANT &other, bool ignore_case=false) const
VARIANT ReleaseAsSafearrayVariant()
void Insert(typename internal::VariantUtil< ExpectedVartype >::Type value)
int Compare(const VARIANT &other, bool ignore_case=false) const
VARIANT ReleaseAsScalarVariant()
#define EXPECT_DCHECK_DEATH(statement)
TEST(Display, ScaleFactorToFloat)
#define EXPECT_TRUE(handle)