refactor Nip19Test introduce byteArrayOfInts()

This commit is contained in:
Chemaclass
2023-03-03 22:46:15 +01:00
parent b6e16ad470
commit 47f3fe5cc6
@@ -7,17 +7,19 @@ class Nip19Test {
@Test(expected = IllegalArgumentException::class) @Test(expected = IllegalArgumentException::class)
fun to_int_32_length_smaller_than_4() { fun to_int_32_length_smaller_than_4() {
toInt32(ByteArray(3)) toInt32(byteArrayOfInts(1, 2, 3))
} }
@Test(expected = IllegalArgumentException::class) @Test(expected = IllegalArgumentException::class)
fun to_int_32_length_bigger_than_4() { fun to_int_32_length_bigger_than_4() {
toInt32(ByteArray(5)) toInt32(byteArrayOfInts(1, 2, 3, 4, 5))
} }
@Test() @Test()
fun to_int_32_length_4() { fun to_int_32_length_4() {
val actual = toInt32(ByteArray(4)) val actual = toInt32(byteArrayOfInts(1, 2, 3, 4))
Assert.assertEquals(0, actual) Assert.assertEquals(16909060, actual)
} }
private fun byteArrayOfInts(vararg ints: Int) = ByteArray(ints.size) { pos -> ints[pos].toByte() }
} }