Add test for skipping map

This commit is contained in:
Him188 2020-03-19 11:07:18 +08:00
parent ecda34deee
commit f068033400

View File

@ -42,6 +42,73 @@ internal const val ZERO_TYPE: Byte = 12
@Suppress("INVISIBLE_MEMBER") // bug
internal class JceInputTest {
@Test
fun testSkippingMap() {
@Serializable
data class TestSerializableClassC(
@JceId(5) val value3: Int = 123123
)
@Serializable
data class TestSerializableClassB(
@JceId(0) val value: Int,
@JceId(123) val nested2: TestSerializableClassC,
@JceId(5) val value5: Int
)
@Serializable
data class TestSerializableClassA(
//@JceId(0) val map: Map<TestSerializableClassB, TestSerializableClassC>
@JceId(1) val optional: String = ""
)
val input = buildPacket {
writeJceHead(MAP, 0) // TestSerializableClassB
writeJceHead(BYTE, 0)
writeByte(1)
writeJceHead(STRUCT_BEGIN, 0);
{
writeJceHead(INT, 0)
writeInt(123)
writeJceHead(STRUCT_BEGIN, 123); // TestSerializableClassC
{
writeJceHead(INT, 5)
writeInt(123123)
}()
writeJceHead(STRUCT_END, 0)
writeJceHead(INT, 5)
writeInt(9)
}()
writeJceHead(STRUCT_END, 0)
writeJceHead(STRUCT_BEGIN, 1);
{
writeJceHead(INT, 5)
writeInt(123123)
}()
writeJceHead(STRUCT_END, 0)
writeJceHead(STRING1, 1)
writeByte(1)
writeStringUtf8("1")
}
assertEquals(
TestSerializableClassA(
/*mapOf(
TestSerializableClassB(123, TestSerializableClassC(123123), 9)
to TestSerializableClassC(123123)
)*/
"1"
),
Jce.UTF_8.load(TestSerializableClassA.serializer(), input)
)
}
@Test
fun testFuckingComprehensiveStruct() {
@Serializable