mirror of
https://github.com/Ku6epXBOCTuK/easy-png-tools.git
synced 2026-09-14 21:46:35 +00:00
feat: core instruments
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
import { expect } from 'vitest';
|
||||
import type { PixelImage } from './types';
|
||||
|
||||
export function makeImage(width: number, height: number, pixels: number[][]): PixelImage {
|
||||
const data = new Uint8ClampedArray(pixels.flat());
|
||||
if (data.length !== width * height * 4) {
|
||||
throw new Error(`Fixture mismatch: ${data.length} байт на ${width}x${height}`);
|
||||
}
|
||||
return { width, height, data };
|
||||
}
|
||||
|
||||
export function expectImageEqual(actual: PixelImage, expectedPixels: number[][]): void {
|
||||
expect([...actual.data]).toEqual(expectedPixels.flat());
|
||||
}
|
||||
Reference in New Issue
Block a user