-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix string quotation for StringSerialization.NONE, fix #17
- Loading branch information
Showing
2 changed files
with
51 additions
and
3 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
36 changes: 36 additions & 0 deletions
36
yamlkt/src/jvmTest/kotlin/net/mamoe/yamlkt/testsFromIssues/17.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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package net.mamoe.yamlkt.testsFromIssues | ||
|
||
import kotlinx.serialization.Serializable | ||
import net.mamoe.yamlkt.Yaml | ||
import org.junit.Test | ||
import kotlin.test.assertEquals | ||
|
||
internal class Issue17 { | ||
private val yaml = Yaml { | ||
// Error without DOUBLE_QUOTATION | ||
//stringSerialization = DOUBLE_QUOTATION | ||
} | ||
|
||
@Serializable | ||
data class TestData( | ||
val test: String, | ||
val test2: String, | ||
val test3: String, | ||
) | ||
|
||
@Test | ||
fun testYaml() { | ||
val data = TestData( | ||
test = "testString", | ||
test2 = "--some \"text {{.val}}\\t{{.another}}\"", | ||
test3 = "\${testString}", | ||
) | ||
|
||
val encodedString = yaml.encodeToString(TestData.serializer(), data) | ||
println(encodedString) | ||
val decodedData = yaml.decodeFromString(TestData.serializer(), encodedString) | ||
println(decodedData) | ||
|
||
assertEquals(data, decodedData) | ||
} | ||
} |