diff --git a/ktoml-core/src/commonTest/kotlin/com/akuleshov7/ktoml/decoders/RequiredAnnotation.kt b/ktoml-core/src/commonTest/kotlin/com/akuleshov7/ktoml/decoders/RequiredAnnotation.kt new file mode 100644 index 00000000..644b6c0a --- /dev/null +++ b/ktoml-core/src/commonTest/kotlin/com/akuleshov7/ktoml/decoders/RequiredAnnotation.kt @@ -0,0 +1,24 @@ +package com.akuleshov7.ktoml.decoders + +import com.akuleshov7.ktoml.Toml +import com.akuleshov7.ktoml.exceptions.MissingRequiredPropertyException +import kotlinx.serialization.Required +import kotlinx.serialization.Serializable +import kotlinx.serialization.decodeFromString +import kotlin.test.Test +import kotlin.test.assertFailsWith + +@Serializable +data class RequiredStr ( + val a: String = "a", + @Required + val b: String = "b", + val c: String, +) + +class RequiredAnnotation { + @Test + fun testMissingRequiredPropertyException() { + assertFailsWith { Toml.decodeFromString("c = \"100\"") } + } +}