-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e4bb37a
commit b849347
Showing
11 changed files
with
137 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 7 additions & 14 deletions
21
ktoml-core/src/commonTest/kotlin/com/akuleshov7/ktoml/decoders/PartialDecoderTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,26 @@ | ||
package com.akuleshov7.ktoml.decoders | ||
|
||
import com.akuleshov7.ktoml.Toml | ||
import io.kotest.matchers.shouldBe | ||
import kotlinx.serialization.ExperimentalSerializationApi | ||
import kotlin.test.Test | ||
import kotlinx.serialization.Serializable | ||
import kotlinx.serialization.serializer | ||
import kotlin.test.assertEquals | ||
|
||
@ExperimentalSerializationApi | ||
class PartialDecoderTest { | ||
@Serializable | ||
data class TwoTomlTables(val table1: Table1, val table2: Table2) | ||
|
||
@Serializable | ||
data class Table1(val a: Long, val b: Long) | ||
|
||
@Serializable | ||
data class Table2(val c: Long, val e: Long, val d: Long) | ||
|
||
@Test | ||
fun testPartialDecoding() { | ||
val test = TwoTomlTables(Table1(1, 2), Table2(1, 2, 3)) | ||
assertEquals( | ||
test.table1, | ||
Toml.partiallyDecodeFromString( | ||
serializer(), | ||
"[table1] \n a = 1 \n b = 2 \n [table2] \n c = 1 \n e = 2 \n d = 3", | ||
"table1" | ||
) | ||
val parsedResult = Toml.partiallyDecodeFromString<Table1>( | ||
serializer(), | ||
"[table1] \n a = 1 \n b = 2 \n [table2] \n c = 1 \n e = 2 \n d = 3", | ||
"table1" | ||
) | ||
|
||
parsedResult shouldBe Table1(1, 2) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.