Skip to content

Commit

Permalink
Don't use kotlinx.datetime for the test as it is not available for
Browse files Browse the repository at this point in the history
wasm/wasi.
  • Loading branch information
pdvrieze committed Jun 19, 2024
1 parent adfb926 commit 7952fdf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
1 change: 0 additions & 1 deletion serialization/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ kotlin {
implementation(projects.serialutil)
implementation(projects.testutil)
implementation(libs.serialization.json)
implementation(libs.datetime)

implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
package nl.adaptivity.xml.serialization.regressions

import io.github.pdvrieze.xmlutil.testutil.assertXmlEquals
import kotlinx.datetime.Instant
import kotlinx.serialization.Contextual
import kotlinx.serialization.Serializable
import kotlinx.serialization.decodeFromString
Expand All @@ -35,19 +34,19 @@ class ContextualWithTypeSerializer220 {
@Serializable
data class Box(
@Contextual
@XmlElement val i: Instant
@XmlElement val i: Long
)

@Test
fun deserializeTest() {
val box: Box = XML.defaultInstance.decodeFromString(
"""<?xml version="1.0" encoding="UTF-8"?>
<Box>
<i>2023-11-02T15:56:49.364+01:00</i>
<i>1698937009364</i>
</Box>""".trimIndent()
)

val expected = Instant.fromEpochMilliseconds(1698937009364L)
val expected = 1698937009364L

assertEquals(expected, box.i)
}
Expand All @@ -56,11 +55,11 @@ class ContextualWithTypeSerializer220 {
fun serializeTest() {
val expected =
"""<Box>
<i>2023-11-02T14:56:49.364Z</i>
<i>1698937009364</i>
</Box>""".trimIndent()


val actual = XML.encodeToString(Box(Instant.fromEpochMilliseconds(1698937009364L)))
val actual = XML.encodeToString(Box(1698937009364L))

assertXmlEquals(expected, actual)
}
Expand Down

0 comments on commit 7952fdf

Please sign in to comment.