@@ -21,36 +21,36 @@ class UnsignedIntegersTest : JsonTestBase() {
21
21
val double : Double
22
22
)
23
23
24
- // TODO uncomment when Kotlin 1.8.0 is released
25
- // @Serializable
26
- // data class UnsignedArrays(
27
- // val uByte: UByteArray,
28
- // val uShort: UShortArray,
29
- // val uInt: UIntArray,
30
- // val uLong: ULongArray
31
- // ) {
32
- // override fun equals(other: Any?): Boolean {
33
- // if (this === other) return true
34
- // if (other == null || this::class != other::class) return false
35
- //
36
- // other as UnsignedArrays
37
- //
38
- // if (!uByte.contentEquals(other.uByte)) return false
39
- // if (!uShort.contentEquals(other.uShort)) return false
40
- // if (!uInt.contentEquals(other.uInt)) return false
41
- // if (!uLong.contentEquals(other.uLong)) return false
42
- //
43
- // return true
44
- // }
45
- //
46
- // override fun hashCode(): Int {
47
- // var result = uByte.contentHashCode()
48
- // result = 31 * result + uShort.contentHashCode()
49
- // result = 31 * result + uInt.contentHashCode()
50
- // result = 31 * result + uLong.contentHashCode()
51
- // return result
52
- // }
53
- // }
24
+ @ExperimentalUnsignedTypes
25
+ @Serializable
26
+ data class UnsignedArrays (
27
+ val uByte : UByteArray ,
28
+ val uShort : UShortArray ,
29
+ val uInt : UIntArray ,
30
+ val uLong : ULongArray
31
+ ) {
32
+ override fun equals (other : Any? ): Boolean {
33
+ if (this == = other) return true
34
+ if (other == null || this ::class != other::class ) return false
35
+
36
+ other as UnsignedArrays
37
+
38
+ if (! uByte.contentEquals(other.uByte)) return false
39
+ if (! uShort.contentEquals(other.uShort)) return false
40
+ if (! uInt.contentEquals(other.uInt)) return false
41
+ if (! uLong.contentEquals(other.uLong)) return false
42
+
43
+ return true
44
+ }
45
+
46
+ override fun hashCode (): Int {
47
+ var result = uByte.contentHashCode()
48
+ result = 31 * result + uShort.contentHashCode()
49
+ result = 31 * result + uInt.contentHashCode()
50
+ result = 31 * result + uLong.contentHashCode()
51
+ return result
52
+ }
53
+ }
54
54
55
55
@Serializable
56
56
data class UnsignedWithoutLong (val uInt : UInt , val uByte : UByte , val uShort : UShort )
@@ -123,18 +123,18 @@ class UnsignedIntegersTest : JsonTestBase() {
123
123
) { l, r -> l.contentEquals(r) }
124
124
}
125
125
126
- // TODO uncomment when Kotlin 1.8.0 is released
127
- // @OptIn(ExperimentalUnsignedTypes::class)
128
- // fun testArrays() {
129
- // val data = UnsignedArrays(
130
- // ubyteArrayOf(1U, 220U),
131
- // ushortArrayOf(1U, 65000U),
132
- // uintArrayOf(1U, 2147483657U),
133
- // ulongArrayOf(1U, 9223372036854775817U)
134
- // )
135
- // val json = """{"uByte":[1,220],uShort:[1,65000],uInt:[1,2147483657],uLong:[1,9223372036854775817]}"""
136
- //
137
- // assertJsonFormAndRestored(UnsignedArrays.serializer(), data, json)
138
- // }
126
+ @OptIn( ExperimentalUnsignedTypes :: class )
127
+ @Test
128
+ fun testArrays () {
129
+ val data = UnsignedArrays (
130
+ ubyteArrayOf(1U , 220U ),
131
+ ushortArrayOf(1U , 65000U ),
132
+ uintArrayOf(1U , 2147483657U ),
133
+ ulongArrayOf(1U , 9223372036854775817U )
134
+ )
135
+ val json = """ {"uByte":[1,220]," uShort" :[1,65000]," uInt" :[1,2147483657]," uLong" :[1,9223372036854775817]}"""
136
+
137
+ assertJsonFormAndRestored(UnsignedArrays .serializer(), data, json)
138
+ }
139
139
140
140
}
0 commit comments