https://kotlinlang.org logo
s

sam

03/11/2019, 10:34 PM
Copy code
init {
    "ByteArray.getShort/putShort" {
      should("parse the short correctly") {

        val (buf, expectedShort) = byteArrayOf(0x00, 0x00) to 0.toShort()
        buf.getShort(0) shouldBe expectedShort

        val array = ByteArray(2)
        array.putShort(0, expectedShort)
        array[0] = 0x42
        array should haveSameContentAs(buf)
      }
    }
  }