#2293 Fixes ShouldContainExactly for collection containing byte arrays #2360
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For ShouldContainExactly to work
ByteArray
,ShortArray
etc we have to use theeq
instead of using defaultequals
.One downside of using
eq
is that it hasNumberEq
which try to do type change for comparing number of different type, for example if we are comparing aInt
with aLong
it will convert theLong
toInt
and then check equality using defaultequals
. This number conversion is not desired forShouldContainExactly
.kotest/kotest-assertions/kotest-assertions-core/src/jvmTest/kotlin/com/sksamuel/kotest/matchers/collections/ShouldContainExactlyTest.kt
Lines 76 to 95 in 0ba1498
So i order to make it work without changing the current behaviour of
shouldBe
(internally useseq
) andShouldContainExactly
I added a flagstrictNumberEq
to control conversion of number type inNumberEq
. The default value for this is keptfalse
.One downside of this is that all implementation of need
Eq
need to keep forwardingstrictNumberEq
whenever they internally calleq
.