mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-12-23 00:57:13 +00:00
fix build
This commit is contained in:
parent
5c0e58caec
commit
bb7d47a33b
@ -9,25 +9,25 @@ import kotlinx.serialization.encoding.Encoder
|
||||
|
||||
internal const val parseModeField = "parse_mode"
|
||||
|
||||
@Serializable(ParseModeSerializerObject::class)
|
||||
@Serializable(ParseModeSerializer::class)
|
||||
sealed interface ParseMode {
|
||||
val parseModeName: String
|
||||
}
|
||||
|
||||
@Serializable(ParseModeSerializerObject::class)
|
||||
@Serializable(ParseModeSerializer::class)
|
||||
object MarkdownParseMode : ParseMode {
|
||||
@Serializable
|
||||
@SerialName(parseModeField)
|
||||
override val parseModeName: String = "Markdown"
|
||||
}
|
||||
|
||||
@Serializable(ParseModeSerializerObject::class)
|
||||
@Serializable(ParseModeSerializer::class)
|
||||
object MarkdownV2ParseMode : ParseMode {
|
||||
@Serializable
|
||||
@SerialName(parseModeField)
|
||||
override val parseModeName: String = "MarkdownV2"
|
||||
}
|
||||
@Serializable(ParseModeSerializerObject::class)
|
||||
@Serializable(ParseModeSerializer::class)
|
||||
object HTMLParseMode : ParseMode {
|
||||
@Serializable
|
||||
@SerialName(parseModeField)
|
||||
@ -47,7 +47,7 @@ typealias HTML = HTMLParseMode
|
||||
var defaultParseMode: ParseMode = HTML
|
||||
|
||||
@RiskFeature
|
||||
object ParseModeSerializerObject : KSerializer<ParseMode> {
|
||||
object ParseModeSerializer : KSerializer<ParseMode> {
|
||||
override val descriptor: SerialDescriptor = String.serializer().descriptor
|
||||
override fun deserialize(decoder: Decoder): ParseMode {
|
||||
return when (decoder.decodeString()) {
|
||||
|
@ -40,13 +40,13 @@ class ChatIdentifierTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class Example(
|
||||
val identifier: ChatIdentifier
|
||||
)
|
||||
|
||||
@Test
|
||||
fun `Deserializing_from_String_must_work_correctly`() {
|
||||
@Serializable
|
||||
data class Example(
|
||||
val identifier: ChatIdentifier
|
||||
)
|
||||
|
||||
Example(chatIdentifierChatId.toChatId()).let { withChatId ->
|
||||
val stringified = TestsJsonFormat.encodeToString(Example.serializer(), withChatId)
|
||||
|
@ -9,6 +9,7 @@ import kotlin.test.assertEquals
|
||||
class ParseModeTests {
|
||||
@Serializable
|
||||
data class Example(
|
||||
@Serializable(ParseModeSerializer::class)
|
||||
val mode: ParseMode
|
||||
)
|
||||
|
||||
|
@ -13,6 +13,7 @@ private val dateTime = DateTime(dateTimeMillis)
|
||||
class TelegramDateTests {
|
||||
@Serializable
|
||||
data class Example(
|
||||
@Serializable(TelegramDateSerializer::class)
|
||||
val dateTime: TelegramDate
|
||||
)
|
||||
@Test
|
||||
|
@ -1,9 +1,9 @@
|
||||
package dev.inmo.tgbotapi.types
|
||||
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.makeString
|
||||
import dev.inmo.tgbotapi.TestsJsonFormat
|
||||
import dev.inmo.tgbotapi.extensions.utils.formatting.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourceSerializer
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.makeString
|
||||
import kotlinx.serialization.builtins.ListSerializer
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
@ -26,9 +26,9 @@ class TextSourcesTests {
|
||||
regular(" ")
|
||||
pre("text", "kotlin")
|
||||
}
|
||||
val serialized = TestsJsonFormat.encodeToString(ListSerializer(TextSource.serializer()), testList)
|
||||
val serialized = TestsJsonFormat.encodeToString(ListSerializer(TextSourceSerializer), testList)
|
||||
val deserialized = TestsJsonFormat.decodeFromString(
|
||||
ListSerializer(TextSource.serializer()),
|
||||
ListSerializer(TextSourceSerializer),
|
||||
serialized
|
||||
)
|
||||
assertEquals(testList, deserialized)
|
||||
|
Loading…
Reference in New Issue
Block a user