( original: ImageData, result: ImageData )
| 84 | * Verifies that algorithm modified the input |
| 85 | */ |
| 86 | export function expectImageModified( |
| 87 | original: ImageData, |
| 88 | result: ImageData |
| 89 | ): void { |
| 90 | expect(result.width).toBe(original.width); |
| 91 | expect(result.height).toBe(original.height); |
| 92 | |
| 93 | // Check that at least some pixels changed |
| 94 | let changedPixels = 0; |
| 95 | for (let i = 0; i < original.data.length; i++) { |
| 96 | if (original.data[i] !== result.data[i]) { |
| 97 | changedPixels++; |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | expect(changedPixels).toBeGreaterThan(0); |
| 102 | } |
| 103 | |
| 104 | /** |
| 105 | * Compares two ImageData objects pixel by pixel |
no outgoing calls
no test coverage detected