30 lines
1.1 KiB
Kotlin
30 lines
1.1 KiB
Kotlin
package solutions.bitbadger.documents
|
|
|
|
import org.junit.jupiter.api.DisplayName
|
|
import org.junit.jupiter.api.Test
|
|
import kotlin.test.assertEquals
|
|
|
|
/**
|
|
* Unit tests for the `ParameterName` class
|
|
*/
|
|
@DisplayName("ParameterName")
|
|
class ParameterNameTest {
|
|
|
|
@Test
|
|
@DisplayName("derive works when given existing names")
|
|
fun withExisting() {
|
|
val names = ParameterName()
|
|
assertEquals(":taco", names.derive(":taco"), "Name should have been :taco")
|
|
assertEquals(":field0", names.derive(null), "Counter should not have advanced for named field")
|
|
}
|
|
|
|
@Test
|
|
@DisplayName("derive works when given all anonymous fields")
|
|
fun allAnonymous() {
|
|
val names = ParameterName()
|
|
assertEquals(":field0", names.derive(null), "Anonymous field name should have been returned")
|
|
assertEquals(":field1", names.derive(null), "Counter should have advanced from previous call")
|
|
assertEquals(":field2", names.derive(null), "Counter should have advanced from previous call")
|
|
assertEquals(":field3", names.derive(null), "Counter should have advanced from previous call")
|
|
}
|
|
} |