-
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.
Adding the support for Char type (#176)
### What's done: - conversion from a literal string to char - enabling some old tests - still we need unicode conversion and fixes for literal strings
- Loading branch information
Showing
16 changed files
with
208 additions
and
112 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
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
5 changes: 0 additions & 5 deletions
5
ktoml-core/src/commonTest/kotlin/com/akuleshov7/ktoml/decoders/ArrayOfTablesDecoderTest.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
46 changes: 46 additions & 0 deletions
46
ktoml-core/src/commonTest/kotlin/com/akuleshov7/ktoml/decoders/CharDecoderTest.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,46 @@ | ||
package com.akuleshov7.ktoml.decoders | ||
|
||
import com.akuleshov7.ktoml.Toml | ||
import kotlinx.serialization.Serializable | ||
import kotlinx.serialization.decodeFromString | ||
import kotlin.test.Ignore | ||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
|
||
|
||
class CharDecoderTest { | ||
@Serializable | ||
data class MyClass( | ||
val a: Char, | ||
val b: Char, | ||
val c: Char, | ||
) | ||
|
||
@Test | ||
fun charBasicTest() { | ||
val test = | ||
""" | ||
a = 123 | ||
b = '4' | ||
c = 'D' | ||
""" | ||
|
||
// FixMe #177: actually this logic is invalid, because Literal Strings should not be making a conversion of str | ||
val decoded = Toml.decodeFromString<MyClass>(test) | ||
assertEquals(decoded, MyClass('{', '4', 'D')) | ||
} | ||
|
||
@Test | ||
@Ignore | ||
fun charUnicodeSymbolsTest() { | ||
val test = | ||
""" | ||
a = '\u0048' | ||
b = '\u0FCA' | ||
c = '\u0002' | ||
""" | ||
|
||
val decoded = Toml.decodeFromString<MyClass>(test) | ||
assertEquals(decoded, MyClass('{', '\n', '\t')) | ||
} | ||
} |
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 |
---|---|---|
|
@@ -66,6 +66,7 @@ class CustomSerializerTest { | |
""".trimIndent() | ||
) | ||
) | ||
UInt.MAX_VALUE | ||
} | ||
|
||
@Serializable | ||
|
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.