This is an automated email from the ASF dual-hosted git repository.
chaokunyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/fury.git
The following commit(s) were added to refs/heads/main by this push:
new d44e27dc feat(kotlin): Add Unsigned Primitive Support (#1886)
d44e27dc is described below
commit d44e27dc0277da8350b6d3c03cbfb689673844ec
Author: Yi Wen Wong <[email protected]>
AuthorDate: Wed Oct 16 06:12:23 2024 -0700
feat(kotlin): Add Unsigned Primitive Support (#1886)
<!--
**Thanks for contributing to Fury.**
**If this is your first time opening a PR on fury, you can refer to
[CONTRIBUTING.md](https://github.com/apache/fury/blob/main/CONTRIBUTING.md).**
Contribution Checklist
- The **Apache Fury (incubating)** community has restrictions on the
naming of pr titles. You can also find instructions in
[CONTRIBUTING.md](https://github.com/apache/fury/blob/main/CONTRIBUTING.md).
- Fury has a strong focus on performance. If the PR you submit will have
an impact on performance, please benchmark it first and provide the
benchmark result here.
-->
## What does this PR do?
This PR adds unsigned primitive support to Kotlin Fury.
It also adds tests for the standard kotlin primitives(supported by fury
Java), nullable primitive tests, boundary tests for unsigned
serializers.
## Related issues
#683
## Does this PR introduce any user-facing change?
Yes it adds Unsigned support for Kotlin. There's documentation new issue
(should add something to document Kotlin!)
- [ ] Does this PR introduce any public API change?
- [ ] Does this PR introduce any binary protocol compatibility change?
## Benchmark
N/A
---------
Co-authored-by: Shawn Yang <[email protected]>
---
kotlin/README.md | 5 +-
.../fury/serializer/kotlin/KotlinSerializers.java | 20 +++
.../fury/serializer/kotlin/KotlinToJavaClass.kt | 7 +
.../fury/serializer/kotlin/UnsignedSerializer.kt | 120 ++++++++++++++
.../kotlin/NullablePrimitiveSerializerTests.kt | 174 +++++++++++++++++++++
.../serializer/kotlin/PrimitiveSerializerTest.kt | 167 ++++++++++++++++++++
.../kotlin/UnsignedBoundarySerializerTests.kt | 91 +++++++++++
7 files changed, 583 insertions(+), 1 deletion(-)
diff --git a/kotlin/README.md b/kotlin/README.md
index 255b2ed6..ab34cd1e 100644
--- a/kotlin/README.md
+++ b/kotlin/README.md
@@ -8,11 +8,14 @@ Fury Kotlin provides additional tests and implementation
support for Kotlin type
Fury Kotlin is tested and works with the following types:
+- primitives: `Byte`, `Boolean`, `Int`, `Short`, `Long`, `Char`, `Float`,
`Double`, `UByte`, `UShort`, `UInt`, `UShort`, `UInt`.
+- `Byte`, `Boolean`, `Int`, `Short`, `Long`, `Char`, `Float`, `Double` works
out of the box with the default fury java implementation.
- stdlib `collection`: `ArrayDeque`, `ArrayList`, `HashMap`,`HashSet`,
`LinkedHashSet`, `LinkedHashMap`.
-- `ArrayList`, `HashMap`,`HashSet`, `LinkedHashSet`, `LinkedHashMap` works out
of the box with the default java implementation.
+- `ArrayList`, `HashMap`,`HashSet`, `LinkedHashSet`, `LinkedHashMap` works out
of the box with the default fury java implementation.
Additional support is added for the following classes in kotlin:
+- Unsigned primitives: `UByte`, `UShort`, `UInt`, `ULong`
- Empty collections: `emptyList`, `emptyMap`, `emptySet`
- Collections: `ArrayDeque`
diff --git
a/kotlin/src/main/java/org/apache/fury/serializer/kotlin/KotlinSerializers.java
b/kotlin/src/main/java/org/apache/fury/serializer/kotlin/KotlinSerializers.java
index 14a368fb..13493fb4 100644
---
a/kotlin/src/main/java/org/apache/fury/serializer/kotlin/KotlinSerializers.java
+++
b/kotlin/src/main/java/org/apache/fury/serializer/kotlin/KotlinSerializers.java
@@ -33,6 +33,26 @@ public class KotlinSerializers {
public static void registerSerializers(Fury fury) {
ClassResolver resolver = fury.getClassResolver();
+ // UByte
+ Class ubyteClass = KotlinToJavaClass.INSTANCE.getUByteClass();
+ resolver.register(ubyteClass);
+ resolver.registerSerializer(ubyteClass, new UByteSerializer(fury));
+
+ // UShort
+ Class ushortClass = KotlinToJavaClass.INSTANCE.getUShortClass();
+ resolver.register(ushortClass);
+ resolver.registerSerializer(ushortClass, new UShortSerializer(fury));
+
+ // UInt
+ Class uintClass = KotlinToJavaClass.INSTANCE.getUIntClass();
+ resolver.register(uintClass);
+ resolver.registerSerializer(uintClass, new UIntSerializer(fury));
+
+ // ULong
+ Class ulongClass = KotlinToJavaClass.INSTANCE.getULongClass();
+ resolver.register(ulongClass);
+ resolver.registerSerializer(ulongClass, new ULongSerializer(fury));
+
// EmptyList
Class emptyListClass = KotlinToJavaClass.INSTANCE.getEmptyListClass();
resolver.register(emptyListClass);
diff --git
a/kotlin/src/main/kotlin/org/apache/fury/serializer/kotlin/KotlinToJavaClass.kt
b/kotlin/src/main/kotlin/org/apache/fury/serializer/kotlin/KotlinToJavaClass.kt
index 824a2ebf..cd962fd6 100644
---
a/kotlin/src/main/kotlin/org/apache/fury/serializer/kotlin/KotlinToJavaClass.kt
+++
b/kotlin/src/main/kotlin/org/apache/fury/serializer/kotlin/KotlinToJavaClass.kt
@@ -20,8 +20,15 @@
package org.apache.fury.serializer.kotlin
object KotlinToJavaClass {
+ // Collections
val ArrayDequeClass = ArrayDeque::class.java
val EmptyListClass = emptyList<Any>().javaClass
val EmptySetClass = emptySet<Any>().javaClass
val EmptyMapClass = emptyMap<Any, Any>().javaClass
+
+ // Unsigned
+ val UByteClass = UByte::class.java
+ val UShortClass = UShort::class.java
+ val UIntClass = UInt::class.java
+ val ULongClass = ULong::class.java
}
diff --git
a/kotlin/src/main/kotlin/org/apache/fury/serializer/kotlin/UnsignedSerializer.kt
b/kotlin/src/main/kotlin/org/apache/fury/serializer/kotlin/UnsignedSerializer.kt
new file mode 100644
index 00000000..109e96e3
--- /dev/null
+++
b/kotlin/src/main/kotlin/org/apache/fury/serializer/kotlin/UnsignedSerializer.kt
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.fury.serializer.kotlin
+
+import org.apache.fury.Fury
+import org.apache.fury.memory.MemoryBuffer
+import org.apache.fury.serializer.Serializers
+import org.apache.fury.type.Type
+
+/**
+ * UByteSerializer
+ *
+ * UByte is mapped to Type.UINT8
+ *
+ */
+class UByteSerializer(
+ fury: Fury,
+) : Serializers.CrossLanguageCompatibleSerializer<UByte>(
+ fury,
+ UByte::class.java,
+ Type.UINT8.id,
+ fury.isBasicTypesRefIgnored,
+ true) {
+
+ override fun write(buffer: MemoryBuffer, value: UByte) {
+ buffer.writeByte(value.toInt())
+ }
+
+ override fun read(buffer: MemoryBuffer): UByte {
+ return buffer.readByte().toUByte()
+ }
+}
+
+
+/**
+ * UShortSerializer
+ *
+ * UShort is mapped to Type.UINT16.
+ *
+ */
+class UShortSerializer(
+ fury: Fury,
+) : Serializers.CrossLanguageCompatibleSerializer<UShort>(
+ fury,
+ UShort::class.java,
+ Type.UINT16.id,
+ fury.isBasicTypesRefIgnored,
+ true
+) {
+ override fun write(buffer: MemoryBuffer, value: UShort) {
+ buffer.writeVarUint32(value.toInt())
+ }
+ override fun read(buffer: MemoryBuffer): UShort {
+ return buffer.readVarUint32().toUShort()
+ }
+}
+
+/**
+ * UInt Serializer
+ *
+ * UInt is mapped to Type.UINT32.
+ *
+ */
+class UIntSerializer(
+ fury: Fury,
+) : Serializers.CrossLanguageCompatibleSerializer<UInt>(
+ fury,
+ UInt::class.java,
+ Type.UINT32.id,
+ fury.isBasicTypesRefIgnored,
+ true) {
+
+ override fun write(buffer: MemoryBuffer, value: UInt) {
+ buffer.writeVarUint32(value.toInt())
+ }
+
+ override fun read(buffer: MemoryBuffer): UInt {
+ return buffer.readVarUint32().toUInt()
+ }
+}
+
+/**
+ * ULong Serializer
+ *
+ * ULong is mapped to Type.UINT64.
+ *
+ */
+class ULongSerializer(
+ fury: Fury,
+) : Serializers.CrossLanguageCompatibleSerializer<ULong>(
+ fury,
+ ULong::class.java,
+ Type.UINT64.id,
+ fury.isBasicTypesRefIgnored,
+ true
+) {
+ override fun write(buffer: MemoryBuffer, value: ULong) {
+ buffer.writeVarUint64(value.toLong())
+ }
+ override fun read(buffer: MemoryBuffer): ULong {
+ return buffer.readVarUint64().toULong()
+ }
+}
diff --git
a/kotlin/src/test/kotlin/org/apache/fury/serializer/kotlin/NullablePrimitiveSerializerTests.kt
b/kotlin/src/test/kotlin/org/apache/fury/serializer/kotlin/NullablePrimitiveSerializerTests.kt
new file mode 100644
index 00000000..366dae4d
--- /dev/null
+++
b/kotlin/src/test/kotlin/org/apache/fury/serializer/kotlin/NullablePrimitiveSerializerTests.kt
@@ -0,0 +1,174 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.fury.serializer.kotlin
+
+import org.apache.fury.Fury
+import org.apache.fury.config.Language
+import org.testng.Assert
+import org.testng.annotations.Test
+
+/**
+ * Nullable primitive serializer tests.
+ *
+ * Nullable primitives get translated into Boxed types in java.
+ * See:
https://kotlinlang.org/docs/numbers.html#numbers-representation-on-the-jvm
+ *
+ */
+class NullablePrimitiveSerializerTests {
+ @Test
+ fun testSerializeBoxedByteValue() {
+ val fury: Fury = Fury.builder()
+ .withLanguage(Language.JAVA)
+ .requireClassRegistration(true)
+ .build()
+
+ KotlinSerializers.registerSerializers(fury)
+ val value:Byte? = 42
+ Assert.assertEquals(value, fury.deserialize(fury.serialize(value)))
+ }
+ @Test
+ fun testSerializeBoxedIntValue() {
+ val fury: Fury = Fury.builder()
+ .withLanguage(Language.JAVA)
+ .requireClassRegistration(true)
+ .build()
+
+ KotlinSerializers.registerSerializers(fury)
+ val value:Int? = 42
+ Assert.assertEquals(value, fury.deserialize(fury.serialize(value)))
+ }
+ @Test
+ fun testSerializeBoxedShortValue() {
+ val fury: Fury = Fury.builder()
+ .withLanguage(Language.JAVA)
+ .requireClassRegistration(true)
+ .build()
+
+ KotlinSerializers.registerSerializers(fury)
+ val value:Short? = 42
+ Assert.assertEquals(value, fury.deserialize(fury.serialize(value)))
+ }
+
+ @Test
+ fun testSerializeBoxedLongValue() {
+ val fury: Fury = Fury.builder()
+ .withLanguage(Language.JAVA)
+ .requireClassRegistration(true)
+ .build()
+
+ KotlinSerializers.registerSerializers(fury)
+ val value:Long? = 42L
+ Assert.assertEquals(value, fury.deserialize(fury.serialize(value)))
+ }
+
+ @Test
+ fun testSerializeBoxedFloatValue() {
+ val fury: Fury = Fury.builder()
+ .withLanguage(Language.JAVA)
+ .requireClassRegistration(true)
+ .build()
+
+ KotlinSerializers.registerSerializers(fury)
+ val value:Float? = .42f
+ Assert.assertEquals(value, fury.deserialize(fury.serialize(value)))
+ }
+
+ @Test
+ fun testSerializeBoxedDoubleValue() {
+ val fury: Fury = Fury.builder()
+ .withLanguage(Language.JAVA)
+ .requireClassRegistration(true)
+ .build()
+
+ KotlinSerializers.registerSerializers(fury)
+ val value: Double? = .42
+ Assert.assertEquals(value, fury.deserialize(fury.serialize(value)))
+ }
+
+ @Test
+ fun testSerializeBoxedBooleanValue() {
+ val fury: Fury = Fury.builder()
+ .withLanguage(Language.JAVA)
+ .requireClassRegistration(true)
+ .build()
+
+ KotlinSerializers.registerSerializers(fury)
+ val value: Boolean? = true
+ Assert.assertEquals(value, fury.deserialize(fury.serialize(value)))
+ }
+ @Test
+ fun testSerializeBoxedCharValue() {
+ val fury: Fury = Fury.builder()
+ .withLanguage(Language.JAVA)
+ .requireClassRegistration(true)
+ .build()
+
+ KotlinSerializers.registerSerializers(fury)
+ val value: Char? = 'a'
+ Assert.assertEquals(value, fury.deserialize(fury.serialize(value)))
+ }
+
+ @Test
+ fun testSerializeBoxedUByteValue() {
+ val fury: Fury = Fury.builder()
+ .withLanguage(Language.JAVA)
+ .requireClassRegistration(true)
+ .build()
+
+ KotlinSerializers.registerSerializers(fury)
+ val value: UByte? = 42u
+ Assert.assertEquals(value, fury.deserialize(fury.serialize(value)))
+ }
+
+ @Test
+ fun testSerializeBoxedUShortValue() {
+ val fury: Fury = Fury.builder()
+ .withLanguage(Language.JAVA)
+ .requireClassRegistration(true)
+ .build()
+
+ KotlinSerializers.registerSerializers(fury)
+ val value: UShort? = 42u
+ Assert.assertEquals(value, fury.deserialize(fury.serialize(value)))
+ }
+
+ @Test
+ fun testSerializeBoxedUIntValue() {
+ val fury: Fury = Fury.builder()
+ .withLanguage(Language.JAVA)
+ .requireClassRegistration(true)
+ .build()
+
+ KotlinSerializers.registerSerializers(fury)
+ val value: UInt? = 42u
+ Assert.assertEquals(value, fury.deserialize(fury.serialize(value)))
+ }
+ @Test
+ fun testSerializeBoxedULongValue() {
+ val fury: Fury = Fury.builder()
+ .withLanguage(Language.JAVA)
+ .requireClassRegistration(true)
+ .build()
+
+ KotlinSerializers.registerSerializers(fury)
+ val value: ULong? = 42u
+ Assert.assertEquals(value, fury.deserialize(fury.serialize(value)))
+ }
+}
diff --git
a/kotlin/src/test/kotlin/org/apache/fury/serializer/kotlin/PrimitiveSerializerTest.kt
b/kotlin/src/test/kotlin/org/apache/fury/serializer/kotlin/PrimitiveSerializerTest.kt
new file mode 100644
index 00000000..73b068c4
--- /dev/null
+++
b/kotlin/src/test/kotlin/org/apache/fury/serializer/kotlin/PrimitiveSerializerTest.kt
@@ -0,0 +1,167 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.fury.serializer.kotlin
+
+import org.apache.fury.Fury
+import org.apache.fury.config.Language
+import org.testng.Assert
+import org.testng.annotations.Test
+
+class PrimitiveSerializerTest {
+ @Test
+ fun testSerializeByteValue() {
+ val fury: Fury = Fury.builder()
+ .withLanguage(Language.JAVA)
+ .requireClassRegistration(true)
+ .build()
+
+ KotlinSerializers.registerSerializers(fury)
+ val value:Byte = 42
+ Assert.assertEquals(value, fury.deserialize(fury.serialize(value)))
+ }
+ @Test
+ fun testSerializeIntValue() {
+ val fury: Fury = Fury.builder()
+ .withLanguage(Language.JAVA)
+ .requireClassRegistration(true)
+ .build()
+
+ KotlinSerializers.registerSerializers(fury)
+ val value:Int = 42
+ Assert.assertEquals(value, fury.deserialize(fury.serialize(value)))
+ }
+ @Test
+ fun testSerializeShortValue() {
+ val fury: Fury = Fury.builder()
+ .withLanguage(Language.JAVA)
+ .requireClassRegistration(true)
+ .build()
+
+ KotlinSerializers.registerSerializers(fury)
+ val value:Short = 42
+ Assert.assertEquals(value, fury.deserialize(fury.serialize(value)))
+ }
+
+ @Test
+ fun testSerializeLongValue() {
+ val fury: Fury = Fury.builder()
+ .withLanguage(Language.JAVA)
+ .requireClassRegistration(true)
+ .build()
+
+ KotlinSerializers.registerSerializers(fury)
+ val value:Long = 42L
+ Assert.assertEquals(value, fury.deserialize(fury.serialize(value)))
+ }
+
+ @Test
+ fun testSerializeFloatValue() {
+ val fury: Fury = Fury.builder()
+ .withLanguage(Language.JAVA)
+ .requireClassRegistration(true)
+ .build()
+
+ KotlinSerializers.registerSerializers(fury)
+ val value:Float = .42f
+ Assert.assertEquals(value, fury.deserialize(fury.serialize(value)))
+ }
+
+ @Test
+ fun testSerializeDoubleValue() {
+ val fury: Fury = Fury.builder()
+ .withLanguage(Language.JAVA)
+ .requireClassRegistration(true)
+ .build()
+
+ KotlinSerializers.registerSerializers(fury)
+ val value: Double = .42
+ Assert.assertEquals(value, fury.deserialize(fury.serialize(value)))
+ }
+
+ @Test
+ fun testSerializeBooleanValue() {
+ val fury: Fury = Fury.builder()
+ .withLanguage(Language.JAVA)
+ .requireClassRegistration(true)
+ .build()
+
+ KotlinSerializers.registerSerializers(fury)
+ val value: Boolean = true
+ Assert.assertEquals(value, fury.deserialize(fury.serialize(value)))
+ }
+ @Test
+ fun testSerializeCharValue() {
+ val fury: Fury = Fury.builder()
+ .withLanguage(Language.JAVA)
+ .requireClassRegistration(true)
+ .build()
+
+ KotlinSerializers.registerSerializers(fury)
+ val value: Char = 'a'
+ Assert.assertEquals(value, fury.deserialize(fury.serialize(value)))
+ }
+
+ @Test
+ fun testSerializeUByteValue() {
+ val fury: Fury = Fury.builder()
+ .withLanguage(Language.JAVA)
+ .requireClassRegistration(true)
+ .build()
+
+ KotlinSerializers.registerSerializers(fury)
+ val value: UByte = 42u
+ Assert.assertEquals(value, fury.deserialize(fury.serialize(value)))
+ }
+
+ @Test
+ fun testSerializeUShortValue() {
+ val fury: Fury = Fury.builder()
+ .withLanguage(Language.JAVA)
+ .requireClassRegistration(true)
+ .build()
+
+ KotlinSerializers.registerSerializers(fury)
+ val value: UShort = 42u
+ Assert.assertEquals(value, fury.deserialize(fury.serialize(value)))
+ }
+
+ @Test
+ fun testSerializeUIntValue() {
+ val fury: Fury = Fury.builder()
+ .withLanguage(Language.JAVA)
+ .requireClassRegistration(true)
+ .build()
+
+ KotlinSerializers.registerSerializers(fury)
+ val value: UInt = 42u
+ Assert.assertEquals(value, fury.deserialize(fury.serialize(value)))
+ }
+ @Test
+ fun testSerializeULongValue() {
+ val fury: Fury = Fury.builder()
+ .withLanguage(Language.JAVA)
+ .requireClassRegistration(true)
+ .build()
+
+ KotlinSerializers.registerSerializers(fury)
+ val value: ULong = 42u
+ Assert.assertEquals(value, fury.deserialize(fury.serialize(value)))
+ }
+}
diff --git
a/kotlin/src/test/kotlin/org/apache/fury/serializer/kotlin/UnsignedBoundarySerializerTests.kt
b/kotlin/src/test/kotlin/org/apache/fury/serializer/kotlin/UnsignedBoundarySerializerTests.kt
new file mode 100644
index 00000000..369bcd71
--- /dev/null
+++
b/kotlin/src/test/kotlin/org/apache/fury/serializer/kotlin/UnsignedBoundarySerializerTests.kt
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.fury.serializer.kotlin
+
+import org.apache.fury.Fury
+import org.apache.fury.config.Language
+import org.testng.Assert
+import org.testng.annotations.Test
+
+class UnsignedBoundarySerializerTests {
+ @Test
+ fun testUByteBoundarySerialization() {
+ val fury: Fury = Fury.builder()
+ .withLanguage(Language.JAVA)
+ .requireClassRegistration(true)
+ .build()
+
+ KotlinSerializers.registerSerializers(fury)
+
+ val boundaryMin = UByte.MIN_VALUE
+ val boundaryMax = UByte.MAX_VALUE
+
+ Assert.assertEquals(boundaryMin,
fury.deserialize(fury.serialize(boundaryMin)))
+ Assert.assertEquals(boundaryMax,
fury.deserialize(fury.serialize(boundaryMax)))
+ }
+
+ @Test
+ fun testUShortBoundarySerialization() {
+ val fury: Fury = Fury.builder()
+ .withLanguage(Language.JAVA)
+ .requireClassRegistration(true)
+ .build()
+
+ KotlinSerializers.registerSerializers(fury)
+
+ val boundaryMin = UShort.MIN_VALUE
+ val boundaryMax = UShort.MAX_VALUE
+
+ Assert.assertEquals(boundaryMin,
fury.deserialize(fury.serialize(boundaryMin)))
+ Assert.assertEquals(boundaryMax,
fury.deserialize(fury.serialize(boundaryMax)))
+ }
+
+ @Test
+ fun testUIntBoundarySerialization() {
+ val fury: Fury = Fury.builder()
+ .withLanguage(Language.JAVA)
+ .requireClassRegistration(true)
+ .build()
+
+ KotlinSerializers.registerSerializers(fury)
+
+ val boundaryMin = UInt.MIN_VALUE
+ val boundaryMax = UInt.MAX_VALUE
+
+ Assert.assertEquals(boundaryMin,
fury.deserialize(fury.serialize(boundaryMin)))
+ Assert.assertEquals(boundaryMax,
fury.deserialize(fury.serialize(boundaryMax)))
+ }
+
+ @Test
+ fun testULongBoundarySerialization() {
+ val fury: Fury = Fury.builder()
+ .withLanguage(Language.JAVA)
+ .requireClassRegistration(true)
+ .build()
+
+ KotlinSerializers.registerSerializers(fury)
+
+ val boundaryMin = ULong.MIN_VALUE
+ val boundaryMax = ULong.MAX_VALUE
+
+ Assert.assertEquals(boundaryMin,
fury.deserialize(fury.serialize(boundaryMin)))
+ Assert.assertEquals(boundaryMax,
fury.deserialize(fury.serialize(boundaryMax)))
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]