-
Notifications
You must be signed in to change notification settings - Fork 683
Description
Which version of Kotest are you using: 5.4.1
Description:
It appears that the shouldContainAnyOf
and shouldNotContainAnyOf
functions do not currently support emptyList as an argument. I would like to propose a change to allow this behavior.
Current Behavior:
When using emptyList as an argument, the behavior is as follows:
listOf(1,2,3) shouldContainAll listOf()
// Mathematically true -> passes as expected
listOf(1,2,3) shouldNotContainAll listOf()
// Mathematically false -> fails as expected
listOf(1,2,3) shouldContainAnyOf listOf()
// Mathematically false -> should fail, and it does fail, but the failure is due to the suggestion to use shouldBeEmpty(), which is misleading.
listOf(1,2,3) shouldNotContainAnyOf listOf()
// Mathematically true -> should pass, but it fails due to the suggestion to use shouldBeEmpty().
Issue:
For shouldContainAnyOf
and shouldNotContainAnyOf
, passing an emptyList should mathematically result in false and true, respectively, regardless of the target list (e.g., listOf(1,2,3)
). The suggestion to use The suggestion to use shouldBeEmpty()
does not seem relevant to these cases.shouldBeEmpty()
seems misplaced, as the focus of the check is typically on the left-hand side.
Proposed Change:
- Allow emptyList as a valid argument for both
shouldContainAnyOf
andshouldNotContainAnyOf
. - Ensure that the behavior aligns with mathematical logic:
<any list> shouldContainAnyOf listOf()
should fail, not because shouldBeEmpty() is not used, but because it logically should fail.<any list> shouldNotContainAnyOf listOf()
should pass.
Additional Information:
Please let me know if further clarification is needed. I am happy to assist in implementing this change if required.