Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArrayIncludes() cannot handle multi-dimension arrays #30

Open
connerk opened this issue Oct 17, 2018 · 1 comment
Open

ArrayIncludes() cannot handle multi-dimension arrays #30

connerk opened this issue Oct 17, 2018 · 1 comment

Comments

@connerk
Copy link
Contributor

connerk commented Oct 17, 2018

example test:

Tests.test("range should contain value").Includes myRange.value2, "myValue"

an error occurs because myRange.Value2 is a 2 dimensional array.

in ArrayIncludes(), called by Includes()
VBA.IsArray(Value(i)) causes an error if Value() is multidimensional

@connerk
Copy link
Contributor Author

connerk commented Oct 17, 2018

quick fix without editing the vba-test library is to run all multi-dimensional arrays through this

Public Function ArrayToFlatCollection(a As Variant) As Collection
    Dim c As New Collection
    Dim item As Variant
    If VBA.TypeName(a) Like "*()" Then
        For Each item In a
          c.Add item
        Next item
    Else
        c.Add a
    End If
    Set ArrayToFlatCollection = c
End Function

as such

Tests.test("range should contain value").Includes ArrayToFlatCollection(myRange.value2), "myValue"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant