Added list creation and unit tests
This commit is contained in:
parent
9ae7596d5e
commit
69a43cc613
|
@ -0,0 +1,13 @@
|
|||
package com.baeldung.collections
|
||||
|
||||
import kotlin.collections.List
|
||||
|
||||
class ListExample {
|
||||
fun createList(): List<String> {
|
||||
return listOf("one", "two", "three")
|
||||
}
|
||||
|
||||
fun createMutableList(): MutableList<String> {
|
||||
return mutableListOf("Berlin", "Kolkata", "London")
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.baeldung.collections
|
||||
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Assertions.assertNotEquals
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
class ListExampleUnitTest {
|
||||
|
||||
private val classUnderTest: ListExample = ListExample()
|
||||
|
||||
@Test
|
||||
fun whenListIsCreated_thenContainsElements() {
|
||||
assertTrue(classUnderTest.createList().contains("two"))
|
||||
assertTrue(classUnderTest.createMutableList().contains("Berlin"))
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue