Consider this pattern of assertions:
@Test
fun test() {
val list = listOf("one", "two", "three")
assertEquals(list.subList(0, 3), list.subList(0, 3).joinToString(" ").split(" "))
assertEquals(list.subList(0, 2), list.subList(0, 2).joinToString(" ").split(" "))
assertEquals(list.subList(0, 1), list.subList(0, 1).joinToString(" ").split(" "))
assertEquals(list.subList(0, 0), list.subList(0, 0).joinToString(" ").split(" "))
}
All lines follow a pattern of descending list size. All assertions pass, except, somewhat inconsistently, the last one. This is because "".split(" ") is not the expected empty list, but instead it's a one-element list containing the empty string.
Is there another way of calling split, or another function, that behaves the way I was expecting as described above?