4
0
Fork 0
mirror of https://github.com/Anvilcraft/modpacktools synced 2024-06-11 06:59:28 +02:00
modpacktools/src/test/kotlin/ley/anvil/modpacktools/util/config/ConfigTomlTest.kt
2020-08-14 11:20:36 +02:00

47 lines
1.1 KiB
Kotlin

package ley.anvil.modpacktools.util.config
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Test
class ConfigTomlTest {
private val toml = ConfigToml().read(
"""
[SomeCategory]
someValue = 123
""".trimIndent()
) as ConfigToml
@Test
fun getPath() {
//String getPath
assertEquals(
123L,
toml.getPath("SomeCategory/someValue")!!
)
//should be null if invalid category
assertNull(toml.getPath("NonExistentCategory/val"))
}
@Test
fun `getPath with invalid path`() {
//should be null if invalid value
assertNull(toml.getPath("SomeCategory/val"))
}
//should throw exception
@Test(expected = MissingConfigValueException::class)
fun `pathOrException with invalid path`() {
toml.pathOrException<Long>("Asd/asd")
}
@Test
fun pathOrException() {
assertEquals(
123L,
toml.pathOrException("SomeCategory/someValue")
)
}
}