Added array extensions test
This commit is contained in:
parent
31a3ef5aa2
commit
1eeed3f243
1 changed files with 23 additions and 0 deletions
23
src/test/kotlin/app/extensions/ArrayExtensionsKtTest.kt
Normal file
23
src/test/kotlin/app/extensions/ArrayExtensionsKtTest.kt
Normal file
|
@ -0,0 +1,23 @@
|
|||
package app.extensions
|
||||
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
import org.junit.jupiter.api.Assertions.*
|
||||
|
||||
internal class ArrayExtensionsTest {
|
||||
@Test
|
||||
fun matchingIndexes() {
|
||||
val array = arrayOf<Int?>(0, 1, 2, 3, null, 5, 6, null)
|
||||
val result = array.matchingIndexes { it == null }
|
||||
assertEquals(result.count(), 2)
|
||||
assertEquals(result[0], 4)
|
||||
assertEquals(result[1], 7)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun matchingIndexes_empty_array() {
|
||||
val array = arrayOf<Int>()
|
||||
val result = array.matchingIndexes { it > 0 }
|
||||
assertEquals(result.count(), 0)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue