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

add-similarity-to-contain (#53) #3939

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AlexCue987
Copy link
Contributor

add search for similarity to contain for example:

         "print a similar key when no exact match" {
            val message = shouldThrow<AssertionError> {
               mapOf(sweetGreenApple to 1, sweetRedApple to 2) should contain(sweetGreenPear, 1)
            }.message
            message shouldContain """
               | expected: Fruit(name=apple, color=green, taste=sweet),
               |  but was: Fruit(name=pear, color=green, taste=sweet),
               |  The following fields did not match:
               |    "name" expected: <"apple">, but was: <"pear">
            """.trimMargin()
         }
         "print entries with same value" {
            val message = shouldThrow<AssertionError> {
               mapOf(sweetGreenApple to 1, sweetRedApple to 2) should contain(sweetGreenPear, 1)
            }.message
            message shouldContain """
               |Same value found for the following entries: [Fruit(name=apple, color=green, taste=sweet)=1]
            """.trimMargin()
         }
         "print entries with similar values" {
            val message = shouldThrow<AssertionError> {
               mapOf(1 to sweetGreenApple, 2 to sweetRedApple) should contain(3, sweetGreenPear)
            }.message
            message shouldContain """
               | expected: Fruit(name=apple, color=green, taste=sweet),
               |  but was: Fruit(name=pear, color=green, taste=sweet),
               |  The following fields did not match:
               |    "name" expected: <"apple">, but was: <"pear">
            """.trimMargin()
         }

@Kantis
Copy link
Member

Kantis commented May 9, 2024

I feel it's kind of ambiguous what we're looking at in the failure messages. Was it the wrong key or value?

Perhaps we should produce a similarity-score for each Map.Entry and just print the closest one, taking both key and value into consideration?

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