Skip to content

Commit 7239153

Browse files
author
Oleg
committed
Add JsonUnquotedLiteral to bypass the JS convertion to integer value
1 parent 6445cc6 commit 7239153

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/commonTest/kotlin/com/github/optimumcode/json/schema/assertions/number/JsonSchemaMultipleOfValidationTest.kt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,24 @@ import io.kotest.assertions.throwables.shouldThrow
77
import io.kotest.core.spec.style.FunSpec
88
import io.kotest.matchers.collections.shouldHaveSize
99
import io.kotest.matchers.shouldBe
10+
import kotlinx.serialization.ExperimentalSerializationApi
1011
import kotlinx.serialization.json.JsonNull
1112
import kotlinx.serialization.json.JsonPrimitive
13+
import kotlinx.serialization.json.JsonUnquotedLiteral
1214
import kotlinx.serialization.json.buildJsonArray
1315
import kotlinx.serialization.json.buildJsonObject
1416

17+
// JsonUnquotedLiteral is used to bypass the JS conversion to integer value
18+
@OptIn(ExperimentalSerializationApi::class)
1519
@Suppress("unused")
1620
class JsonSchemaMultipleOfValidationTest : FunSpec() {
1721
init {
1822
listOf(
1923
JsonPrimitive(7),
2024
JsonPrimitive(49),
21-
JsonPrimitive(49.0),
25+
JsonUnquotedLiteral("49.0"),
2226
JsonPrimitive(-49),
23-
JsonPrimitive(-49.0),
27+
JsonUnquotedLiteral("-49.0"),
2428
).forEach {
2529
val schema = JsonSchema.fromDescription(
2630
"""
@@ -40,10 +44,10 @@ class JsonSchemaMultipleOfValidationTest : FunSpec() {
4044

4145
listOf(
4246
JsonPrimitive(3),
43-
JsonPrimitive(3.0),
47+
JsonUnquotedLiteral("3.0"),
4448
JsonPrimitive(4.5),
4549
JsonPrimitive(-3),
46-
JsonPrimitive(-3.0),
50+
JsonUnquotedLiteral("-3.0"),
4751
JsonPrimitive(-4.5),
4852
).forEach {
4953
val schema = JsonSchema.fromDescription(
@@ -64,9 +68,9 @@ class JsonSchemaMultipleOfValidationTest : FunSpec() {
6468

6569
listOf(
6670
JsonPrimitive(0),
67-
JsonPrimitive(0.0),
71+
JsonUnquotedLiteral("0.0"),
6872
JsonPrimitive(-1),
69-
JsonPrimitive(-1.0),
73+
JsonUnquotedLiteral("-1.0"),
7074
JsonPrimitive(-Double.MAX_VALUE),
7175
JsonPrimitive(Long.MIN_VALUE),
7276
).forEach {

0 commit comments

Comments
 (0)