ross_a
07/28/2018, 12:16 PMclass ByteDelegateFailing(
private val position: Int,
private val uIntValue: KProperty0<UInt>
) {
operator fun getValue(any: Any?, property: KProperty<*>): UByte {
val uInt = uIntValue.get() shr (position * 8) and 0xffu
return uInt.toUByte()
}
}
and a test
class JvmByteDelegateTest {
val uInt = 0xA1B2C3u
val b2 by ByteDelegateFailing(0, this::uInt)
@Test
fun `Failing example`() {
val actual = b2
assertEquals(0xC3u, actual)
}
}