Skip to content

itemIndexOf, itemLastIndexOf matchers #27

@jeromedecoster

Description

@jeromedecoster

Hello,

I don't know if it's possible with the actual base Matchers, but it could be usefull to have something like this :

itemIndexOf, itemLastIndexOf

// I don't know if it's the best implementation :
assertThat(["a", "b", "c"], itemIndexOf("b", equalTo(0))) // FALSE
assertThat(["a", "b", "c"], itemIndexOf("b", lessThanOrEqualTo(1))) // TRUE
assertThat(["a", "b", "c"], itemIndexOf("e", equalTo(-1))) // TRUE

Usefull to :

  • test position an item in an array ("b" at [1])
  • test a position of 2 items in an array ("a" before "b")

Thanks !

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions