Format code

This new indentation style for nested calls is annoying, I need to see
if it can be turned off somehow...

Signed-off-by: Graham <gpe@openrs2.org>
Graham 4 years ago
parent 4aa75c8fee
commit 9ddce82df4
  1. 34
      cache/src/test/kotlin/org/openrs2/cache/Js5MasterIndexTest.kt
  2. 38
      protocol/src/test/kotlin/org/openrs2/protocol/Rs2DecoderTest.kt
  3. 32
      protocol/src/test/kotlin/org/openrs2/protocol/Rs2EncoderTest.kt

@ -10,11 +10,13 @@ import kotlin.test.assertEquals
object Js5MasterIndexTest { object Js5MasterIndexTest {
private val ROOT = Paths.get(FlatFileStoreTest::class.java.getResource("master-index").toURI()) private val ROOT = Paths.get(FlatFileStoreTest::class.java.getResource("master-index").toURI())
private val encoded = byteArrayOf(0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 2, 0, 0, 0, 5, 0, 0, 0, 4) private val encoded = byteArrayOf(0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 2, 0, 0, 0, 5, 0, 0, 0, 4)
private val decoded = Js5MasterIndex(mutableListOf( private val decoded = Js5MasterIndex(
Js5MasterIndex.Entry(0, 1), mutableListOf(
Js5MasterIndex.Entry(2, 3), Js5MasterIndex.Entry(0, 1),
Js5MasterIndex.Entry(4, 5) Js5MasterIndex.Entry(2, 3),
)) Js5MasterIndex.Entry(4, 5)
)
)
@Test @Test
fun testCreate() { fun testCreate() {
@ -22,15 +24,19 @@ object Js5MasterIndexTest {
Js5MasterIndex.create(store) Js5MasterIndex.create(store)
} }
assertEquals(Js5MasterIndex(mutableListOf( assertEquals(
Js5MasterIndex.Entry(0, 379203374), Js5MasterIndex(
Js5MasterIndex.Entry(0x12345678, -717247318), mutableListOf(
Js5MasterIndex.Entry(0, 0), Js5MasterIndex.Entry(0, 379203374),
Js5MasterIndex.Entry(0x9ABCDEF0.toInt(), 895417101), Js5MasterIndex.Entry(0x12345678, -717247318),
Js5MasterIndex.Entry(0, 0), Js5MasterIndex.Entry(0, 0),
Js5MasterIndex.Entry(0, 0), Js5MasterIndex.Entry(0x9ABCDEF0.toInt(), 895417101),
Js5MasterIndex.Entry(0xAA55AA55.toInt(), -627983571) Js5MasterIndex.Entry(0, 0),
)), index) Js5MasterIndex.Entry(0, 0),
Js5MasterIndex.Entry(0xAA55AA55.toInt(), -627983571)
)
), index
)
} }
@Test @Test

@ -70,14 +70,18 @@ object Rs2DecoderTest {
} }
private fun testDecode(buf: ByteArray, expected: Packet) { private fun testDecode(buf: ByteArray, expected: Packet) {
val channel = EmbeddedChannel(Rs2Decoder(Protocol( val channel = EmbeddedChannel(
FixedPacketCodec, Rs2Decoder(
VariableBytePacketCodec, Protocol(
VariableShortPacketCodec, FixedPacketCodec,
VariableByteOptimisedPacketCodec, VariableBytePacketCodec,
VariableShortOptimisedPacketCodec, VariableShortPacketCodec,
TestEmptyPacketCodec VariableByteOptimisedPacketCodec,
))) VariableShortOptimisedPacketCodec,
TestEmptyPacketCodec
)
)
)
channel.writeInbound(Unpooled.wrappedBuffer(buf)) channel.writeInbound(Unpooled.wrappedBuffer(buf))
val actual = channel.readInbound<Packet>() val actual = channel.readInbound<Packet>()
@ -85,13 +89,17 @@ object Rs2DecoderTest {
} }
private fun testFragmented(buf: ByteArray, expected: Packet) { private fun testFragmented(buf: ByteArray, expected: Packet) {
val channel = EmbeddedChannel(Rs2Decoder(Protocol( val channel = EmbeddedChannel(
FixedPacketCodec, Rs2Decoder(
VariableBytePacketCodec, Protocol(
VariableShortPacketCodec, FixedPacketCodec,
VariableByteOptimisedPacketCodec, VariableBytePacketCodec,
VariableShortOptimisedPacketCodec VariableShortPacketCodec,
))) VariableByteOptimisedPacketCodec,
VariableShortOptimisedPacketCodec
)
)
)
for (b in buf) { for (b in buf) {
channel.writeInbound(wrappedBuffer(b)) channel.writeInbound(wrappedBuffer(b))

@ -21,10 +21,14 @@ object Rs2EncoderTest {
@Test @Test
fun testTooLong() { fun testTooLong() {
val channel = EmbeddedChannel(Rs2Encoder(Protocol( val channel = EmbeddedChannel(
VariableBytePacketCodec, Rs2Encoder(
VariableShortPacketCodec Protocol(
))) VariableBytePacketCodec,
VariableShortPacketCodec
)
)
)
channel.writeOutbound(VariableShortPacket(ByteArray(255))) channel.writeOutbound(VariableShortPacket(ByteArray(255)))
channel.readOutbound<ByteBuf>().release() channel.readOutbound<ByteBuf>().release()
@ -108,14 +112,18 @@ object Rs2EncoderTest {
} }
private fun testEncode(packet: Packet, expected: ByteArray) { private fun testEncode(packet: Packet, expected: ByteArray) {
val channel = EmbeddedChannel(Rs2Encoder(Protocol( val channel = EmbeddedChannel(
FixedPacketCodec, Rs2Encoder(
VariableBytePacketCodec, Protocol(
VariableShortPacketCodec, FixedPacketCodec,
VariableByteOptimisedPacketCodec, VariableBytePacketCodec,
VariableShortOptimisedPacketCodec, VariableShortPacketCodec,
TestEmptyPacketCodec VariableByteOptimisedPacketCodec,
))) VariableShortOptimisedPacketCodec,
TestEmptyPacketCodec
)
)
)
channel.writeOutbound(packet) channel.writeOutbound(packet)
channel.readOutbound<ByteBuf>().use { actual -> channel.readOutbound<ByteBuf>().use { actual ->

Loading…
Cancel
Save