(i: number | bigint)
| 12 | } from "./varint.ts"; |
| 13 | |
| 14 | function encodeDecode(i: number | bigint) { |
| 15 | const [buf, n] = encodeVarint(i, new Uint8Array(MaxVarintLen64)); |
| 16 | const fn = (typeof i === "bigint") ? decodeVarint : decodeVarint32; |
| 17 | const [j, m] = fn(buf); |
| 18 | assertEquals(i, j, `${fn.name}(encodeVarint(${i})): ${i} !== ${j}`); |
| 19 | assertEquals( |
| 20 | n, |
| 21 | m, |
| 22 | `${fn.name}(encodeVarint(${i})): buffer lengths ${n} !== ${m}`, |
| 23 | ); |
| 24 | } |
| 25 | |
| 26 | Deno.test("decodeVarint() handles empty buff", () => { |
| 27 | assertThrows(() => decodeVarint(Uint8Array.of()), RangeError); |
no test coverage detected