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

haveElementAt-more-detail (#49) #3933

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

AlexCue987
Copy link
Member

add more detail to the output of haveElementAt, such as:


         "print if list is too short" {
            shouldThrowAny {
               listOf("a", "b", "c").shouldHaveElementAt(3, "d")
            }.message shouldBe """
            |Collection ["a", "b", "c"] should contain "d" at index 3
            |But it is too short: only 3 elements
            """.trimMargin()
         }
         "print if element does not match" {
            shouldThrowAny {
               listOf("a", "b", "c").shouldHaveElementAt(2, "d")
            }.message shouldBe """
            |Collection ["a", "b", "c"] should contain "d" at index 2
            |Expected: <"c">, but was <"d">
            """.trimMargin()
         }
         "print if element found at another index" {
            shouldThrowAny {
               listOf("a", "b", "c").shouldHaveElementAt(2, "b")
            }.message shouldBe """
            |Collection ["a", "b", "c"] should contain "b" at index 2
            |Expected: <"c">, but was <"b">
            |Element was found at index(es): [1]
            """.trimMargin()
         }
         "print if element found at multiple other indexes" {
            shouldThrowAny {
               listOf("a", "b", "c", "b").shouldHaveElementAt(2, "b")
            }.message shouldBe """
            |Collection ["a", "b", "c", "b"] should contain "b" at index 2
            |Expected: <"c">, but was <"b">
            |Element was found at index(es): [1, 3]
            """.trimMargin()
         }

@sksamuel sksamuel self-requested a review May 19, 2024 15:27
@sksamuel sksamuel enabled auto-merge May 19, 2024 15:27
@sksamuel
Copy link
Member

lgtm

auto-merge was automatically disabled May 30, 2024 12:55

Head branch was pushed to by a user without write access

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

Successfully merging this pull request may close these issues.

None yet

2 participants