Skip to content

Commit dc31cbe

Browse files
committed
Test flattenIfPossible
1 parent 0c82197 commit dc31cbe

File tree

1 file changed

+49
-0
lines changed
  • runtime/runtime-core/common/test/aws/smithy/kotlin/runtime/util

1 file changed

+49
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package aws.smithy.kotlin.runtime.util
2+
3+
import kotlin.test.Test
4+
import kotlin.test.assertEquals
5+
import kotlin.test.assertTrue
6+
7+
class JmesPathTest {
8+
@Test
9+
fun flattenNestedLists() {
10+
val nestedList = listOf(
11+
listOf(1, 2, 3),
12+
listOf(4, 5),
13+
listOf(6),
14+
)
15+
val flattenedList = nestedList.flattenIfPossible()
16+
assertEquals(listOf(1, 2, 3, 4, 5, 6), flattenedList)
17+
}
18+
19+
@Test
20+
fun flattenEmptyNestedLists() {
21+
val nestedList = listOf(
22+
listOf<Int>(),
23+
listOf(),
24+
listOf(),
25+
)
26+
val flattenedList = nestedList.flattenIfPossible()
27+
assertTrue(flattenedList.isEmpty())
28+
}
29+
30+
@Test
31+
fun flattenNestedEmptyAndNonEmptyNestedLists() {
32+
val nestedList = listOf(
33+
listOf(1, 2),
34+
listOf(),
35+
listOf(3, 4, 5),
36+
)
37+
val flattenedList = nestedList.flattenIfPossible()
38+
assertEquals(listOf(1, 2, 3, 4, 5), flattenedList)
39+
}
40+
41+
@Test
42+
fun flattenList() {
43+
val nestedList = listOf(
44+
listOf(1, 2, 3),
45+
)
46+
val flattenedList = nestedList.flattenIfPossible()
47+
assertEquals(listOf(1, 2, 3), flattenedList)
48+
}
49+
}

0 commit comments

Comments
 (0)