Skip to content

Commit dc9873a

Browse files
committed
add test
1 parent a0ccfde commit dc9873a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/commonTest/kotlin/ToolSerializationTest.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package io.modelcontextprotocol.kotlin.sdk
33
import io.kotest.assertions.json.shouldEqualJson
44
import io.modelcontextprotocol.kotlin.sdk.shared.McpJson
55
import kotlinx.serialization.encodeToString
6+
import kotlinx.serialization.json.Json
67
import kotlinx.serialization.json.JsonPrimitive
78
import kotlinx.serialization.json.buildJsonObject
89
import kotlin.test.Test
@@ -54,4 +55,11 @@ class ToolSerializationTest {
5455
assertEquals(expected = getWeatherTool, actual = tool)
5556
}
5657

57-
}
58+
@Test
59+
fun `should always serialize field with default value`() {
60+
val json = Json(from = McpJson) {
61+
encodeDefaults = false
62+
}
63+
json.encodeToString(getWeatherTool) shouldEqualJson getWeatherToolJson
64+
}
65+
}

0 commit comments

Comments
 (0)