```fun haveSameContentAs(expected: ByteArray) = ob...
# kotlintest
b
Copy code
fun haveSameContentAs(expected: ByteArray) = object : Matcher<ByteArray> {
    override fun test(value: ByteArray): Result {
        var matches = true
        if (expected.size != value.size) {
            matches = false
        } else {
            for (i in (0 until expected.size)) {
                if (value.get(i) != expected.get(i)) {
                    matches = false
                    break
                }
            }
        }
        return Result(matches,
            "ByteArray\n${value.toHex()}\nwas supposed to be:\n${expected.toHex()}",
            "Buffer\n${value.toHex()}\nshould not have equaled buffer\n${expected.toHex()}"
        )
    }
}