(
actual: A[], expected: E[], comparator: (actual: A, expected: E) => true | string)
| 57 | } |
| 58 | |
| 59 | export function matchArray<A, E>( |
| 60 | actual: A[], expected: E[], comparator: (actual: A, expected: E) => true | string): true|string { |
| 61 | if (actual.length !== expected.length) { |
| 62 | return `Expected [${actual.map(x => `"${x}"`).join(', ')}] to have length ${expected.length}`; |
| 63 | } |
| 64 | |
| 65 | for (let i = 0; i < expected.length; ++i) { |
| 66 | const result = comparator(actual[i], expected[i]); |
| 67 | if (result !== true) { |
| 68 | return `Mismatch in row ${i}: ${result}`; |
| 69 | } |
| 70 | } |
| 71 | return true; |
| 72 | } |
| 73 | |
| 74 | export function assertOk<Args extends unknown[]>(check: (...args: Args) => true | string) { |
| 75 | return (...args: Args) => { |
no test coverage detected