Skip to content

Commit b8f8110

Browse files
committed
test: add test for InversePayload with FixedInt annotation and update TestClasses
1 parent 0e786c2 commit b8f8110

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

src/test/kotlin/com/eignex/kencode/PackedFormatTest.kt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,4 +301,25 @@ class PackedFormatTest {
301301
)
302302
assertEquals(payload, decoded)
303303
}
304+
305+
@Test
306+
fun `builder defaultVarInt is overridden by FixedInt annotation`() {
307+
val payload = InversePayload(5, -10L, 6u, 7uL)
308+
309+
val optimizedFormat = PackedFormat {
310+
defaultVarInt = true
311+
defaultZigZag = true
312+
}
313+
314+
val bytes = optimizedFormat.encodeToByteArray(
315+
InversePayload.serializer(),
316+
payload
317+
)
318+
assertEquals(24, bytes.size)
319+
val decoded = optimizedFormat.decodeFromByteArray(
320+
InversePayload.serializer(),
321+
bytes
322+
)
323+
assertEquals(payload, decoded)
324+
}
304325
}

src/test/kotlin/com/eignex/kencode/TestClasses.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,3 +630,11 @@ data class PolymorphicContainer(
630630

631631
@Serializable
632632
data class UnannotatedPayload(val x: Int, val y: Long)
633+
634+
@Serializable
635+
data class InversePayload(
636+
@FixedInt val fixedX: Int,
637+
@FixedInt val fixedY: Long,
638+
@FixedInt val fixedUX: UInt,
639+
@FixedInt val fixedUY: ULong
640+
)

0 commit comments

Comments
 (0)