JAVA-2140: Remove Initializing Arrays in Kotlin from the core-kotlin-lang-2

This commit is contained in:
Krzysztof Woyke 2020-07-13 15:51:15 +02:00
parent 44fd4f91b4
commit 26d9b36335
2 changed files with 0 additions and 50 deletions

View File

@ -7,7 +7,6 @@ This module contains articles about core features in the Kotlin language.
- [Infix Functions in Kotlin](https://www.baeldung.com/kotlin-infix-functions) - [Infix Functions in Kotlin](https://www.baeldung.com/kotlin-infix-functions)
- [Lambda Expressions in Kotlin](https://www.baeldung.com/kotlin-lambda-expressions) - [Lambda Expressions in Kotlin](https://www.baeldung.com/kotlin-lambda-expressions)
- [Creating Java static final Equivalents in Kotlin](https://www.baeldung.com/kotlin-java-static-final) - [Creating Java static final Equivalents in Kotlin](https://www.baeldung.com/kotlin-java-static-final)
- [Initializing Arrays in Kotlin](https://www.baeldung.com/kotlin-initialize-array)
- [Lazy Initialization in Kotlin](https://www.baeldung.com/kotlin-lazy-initialization) - [Lazy Initialization in Kotlin](https://www.baeldung.com/kotlin-lazy-initialization)
- [Comprehensive Guide to Null Safety in Kotlin](https://www.baeldung.com/kotlin-null-safety) - [Comprehensive Guide to Null Safety in Kotlin](https://www.baeldung.com/kotlin-null-safety)
- [Kotlin Scope Functions](https://www.baeldung.com/kotlin-scope-functions) - [Kotlin Scope Functions](https://www.baeldung.com/kotlin-scope-functions)

View File

@ -1,49 +0,0 @@
package com.baeldung.arrayinitialization
import org.junit.Test
import kotlin.test.assertEquals
class ArrayInitializationTest {
@Test
fun givenArrayOfStrings_thenValuesPopulated() {
val strings = arrayOf("January", "February", "March")
assertEquals(3, strings.size)
assertEquals("March", strings[2])
}
@Test
fun givenArrayOfIntegers_thenValuesPopulated() {
val integers = intArrayOf(1, 2, 3, 4)
assertEquals(4, integers.size)
assertEquals(1, integers[0])
}
@Test
fun givenArrayOfNulls_whenPopulated_thenValuesPresent() {
val array = arrayOfNulls<Number>(5)
for (i in array.indices) {
array[i] = i * i
}
assertEquals(16, array[4])
}
@Test
fun whenGeneratorUsed_thenValuesPresent() {
val generatedArray = IntArray(10) { i -> i * i }
assertEquals(81, generatedArray[9])
}
@Test
fun whenStringGenerated_thenValuesPresent() {
val generatedStringArray = Array(10) { i -> "Number of index: $i" }
assertEquals("Number of index: 0", generatedStringArray[0])
}
}