Hi All, suppose that I have 2 lists `List<A>...
# kotest
x
Hi All, suppose that I have 2 lists
List<A>
&
List<B>
and a function
f: (A, B) -> Boolean
. I want to assert that for every element in
listA
there's only one element in
listB
so that
f(a, b)
is true.
Copy code
listA.forEach { a ->
  listB
    .filter { f(a, it) }
    .shouldBeSingleton()
}
I want to print out the element
a
that makes the assertion fail. How could I do that?
s
Could do something like,
Copy code
listA.forEach { a ->
   listB.forOne { b ->
    f(a, b) shouldBe true
   }
}