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