Resolve inspections

Signed-off-by: Graham <gpe@openrs2.dev>
pull/132/head
Graham 4 years ago
parent b2a7464da2
commit 192d5b9e8d
  1. 2
      crypto/src/test/java/dev/openrs2/crypto/WhirlpoolTest.kt
  2. 20
      util/src/main/java/dev/openrs2/util/charset/ModifiedUtf8Charset.kt
  3. 1
      util/src/main/java/dev/openrs2/util/io/InputStreamExtensions.kt
  4. 2
      util/src/test/java/dev/openrs2/util/collect/ForestDisjointSetTest.kt

@ -8,7 +8,7 @@ import kotlin.test.Test
object WhirlpoolTest { object WhirlpoolTest {
private class IsoTestVector(input: String, expected: String) { private class IsoTestVector(input: String, expected: String) {
val input = input.toByteArray(Charsets.US_ASCII) val input = input.toByteArray(Charsets.US_ASCII)
val expected = ByteBufUtil.decodeHexDump(expected) val expected: ByteArray = ByteBufUtil.decodeHexDump(expected)
} }
private val ISO_TEST_VECTORS = listOf( private val ISO_TEST_VECTORS = listOf(

@ -31,15 +31,17 @@ public object ModifiedUtf8Charset : Charset("ModifiedUtf8", null) {
return CoderResult.OVERFLOW return CoderResult.OVERFLOW
} }
if (len == 1) { when (len) {
output.put(char.toByte()) 1 -> output.put(char.toByte())
} else if (len == 2) { 2 -> {
output.put((0xC0 or ((char.toInt() shr 6) and 0x1F)).toByte()) output.put((0xC0 or ((char.toInt() shr 6) and 0x1F)).toByte())
output.put((0x80 or (char.toInt() and 0x3F)).toByte()) output.put((0x80 or (char.toInt() and 0x3F)).toByte())
} else { }
output.put((0xE0 or ((char.toInt() shr 12) and 0x1F)).toByte()) else -> {
output.put((0x80 or ((char.toInt() shr 6) and 0x1F)).toByte()) output.put((0xE0 or ((char.toInt() shr 12) and 0x1F)).toByte())
output.put((0x80 or (char.toInt() and 0x3F)).toByte()) output.put((0x80 or ((char.toInt() shr 6) and 0x1F)).toByte())
output.put((0x80 or (char.toInt() and 0x3F)).toByte())
}
} }
} }

@ -25,6 +25,7 @@ public fun InputStream.contentEquals(other: InputStream): Boolean {
remaining -= n2 remaining -= n2
} }
@Suppress("ReplaceJavaStaticMethodWithKotlinAnalog")
if (!Arrays.equals(buf1, 0, n1, buf2, 0, n1)) { if (!Arrays.equals(buf1, 0, n1, buf2, 0, n1)) {
return false return false
} }

@ -112,7 +112,7 @@ object ForestDisjointSetTest {
set.union(set1, set.add(2)) set.union(set1, set.add(2))
set.union(set1, set.add(3)) set.union(set1, set.add(3))
assertEquals(setOf(1, 2, 3), set1.asSequence().toSet()) assertEquals(setOf(1, 2, 3), set1.toSet())
} }
@Test @Test

Loading…
Cancel
Save