function checkEncoded(encoder, bytes, detail) {
  const encoded = (encoder instanceof Encoder) ? encoder.buffer : encoder
  const expected = new Uint8Array(bytes)
  const message = (detail ? `${detail}: ` : '') + `${encoded} expected to equal ${expected}`
  assert(encoded.byteLength === expected.byteLength, message)
  for (let i = 0; i < encoded.byteLength; i++) {
    assert(encoded[i] === expected[i], message)
  }
}
Asserts that the byte array maintained by `encoder` contains the same byte
sequence as the array `bytes`.