Skip to content

Commit

Permalink
Add test for IVector being IIterable.
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanlabelle committed Apr 14, 2024
1 parent 96bd875 commit 6d27d67
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/test_app/CollectionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ class CollectionTests : XCTestCase {
XCTAssertEqual(vector2[2], "Goodnight")
}

public func testArrayVectorIsIterable() throws {
XCTAssertNotNil(try CollectionTester.vectorToIterable(["a", "b", "c"].toVector()))
}

public func testVectorObject_toCallback() throws {
let person = Person(firstName: "John", lastName: "Doe", age: 42)
let array:[Any?] = [person, "Goodbye", 1]
Expand Down Expand Up @@ -88,6 +92,7 @@ var collectionTests: [XCTestCaseEntry] = [
("testVector_asInput", CollectionTests.testVector_asInput),
("testVector_asReturn", CollectionTests.testVector_asReturn),
("testVector_mutate", CollectionTests.testVector_mutate),
("testArrayVectorIsIterable", CollectionTests.testArrayVectorIsIterable),
("testVectorObject_toCallback", CollectionTests.testVectorObject_toCallback),
])
]
5 changes: 5 additions & 0 deletions tests/test_component/cpp/CollectionTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ namespace winrt::test_component::implementation
callback(item);
}

winrt::Windows::Foundation::Collections::IIterable<hstring> CollectionTester::VectorAsIterable(winrt::Windows::Foundation::Collections::IVector<hstring> const& value)
{
return value.as<Windows::Foundation::Collections::IIterable<hstring>>();
}

Windows::Foundation::Collections::IVector<hstring> CollectionTester::ReturnStoredStringVector()
{
if (m_vector.Size() == 0)
Expand Down
1 change: 1 addition & 0 deletions tests/test_component/cpp/CollectionTester.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace winrt::test_component::implementation
static hstring InVector(winrt::Windows::Foundation::Collections::IVector<hstring> const& value);
static hstring InVectorView(winrt::Windows::Foundation::Collections::IVectorView<hstring> const& value);
static void GetObjectAt(winrt::Windows::Foundation::Collections::IVector<winrt::Windows::Foundation::IInspectable> const& value, uint32_t index, winrt::test_component::ObjectHandler const& callback);
static winrt::Windows::Foundation::Collections::IIterable<hstring> VectorAsIterable(winrt::Windows::Foundation::Collections::IVector<hstring> const& value);

winrt::Windows::Foundation::Collections::IVector<hstring> ReturnStoredStringVector();
winrt::Windows::Foundation::Collections::IMap<hstring, hstring> ReturnMapFromStringToString();
Expand Down
1 change: 1 addition & 0 deletions tests/test_component/cpp/CollectionTester.idl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace test_component
static String InVector(Windows.Foundation.Collections.IVector<String> value);
static String InVectorView(Windows.Foundation.Collections.IVectorView<String> value);
static void GetObjectAt(Windows.Foundation.Collections.IVector<Object> value, UInt32 index, ObjectHandler callback);
static Windows.Foundation.Collections.IIterable<String> VectorAsIterable(Windows.Foundation.Collections.IVector<String> value);

Windows.Foundation.Collections.IVector<String> ReturnStoredStringVector();
Windows.Foundation.Collections.IMap<String, String> ReturnMapFromStringToString();
Expand Down

0 comments on commit 6d27d67

Please sign in to comment.