LeoColman
05/22/2020, 6:27 AMshouldContainExactly
might fit your usecase, but if you really want to create a custom matcher, it's not very hard:JP
05/22/2020, 7:28 AMshouldContainExactly
, you mean collections.shouldContainExactly
in matchers, and in order to use this I would have to make the data structure be a subclass of Kotlin’s Collection
, right?
Currently my usecase is simple, I’m just practicing Kotlin with problem solving via leetcode, and leetcode has some predefined data structure classes such as:
class ListNode(var `val`: Int) {
var next: ListNode? = null
}
Then I wanted to make custom functions for testing locally with kotest, where I have written a function like
fun linkedListOf(vararg elements: Int): ListNode
where it creates a singly linked list with a syntax like linkedListOf(1, 2, 3)
and returns the head ListNode
.LeoColman
05/22/2020, 9:00 PMJP
05/24/2020, 1:16 PMCollection
myself and then used kotest’s shouldContainExactly
matcher. Next I’ll try to create this custom matchers. Thanks for the info!Result
instead of MatcherResult
?LeoColman
05/24/2020, 11:35 PM