Initial Commit
This commit is contained in:
37
packages/foundation/flow/streams-metadata/tests/fixtures.ts
Normal file
37
packages/foundation/flow/streams-metadata/tests/fixtures.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* Inline binary fixtures shared by the streams-metadata test suite. Each
|
||||
* helper produces the minimum bytes required to exercise a specific code
|
||||
* path without pulling in real image files.
|
||||
*/
|
||||
|
||||
export function buildMinimalJpeg(): Uint8Array {
|
||||
const soi = new Uint8Array([0xff, 0xd8]);
|
||||
const sos = new Uint8Array([
|
||||
0xff, 0xda, 0x00, 0x08, 0x01, 0x01, 0x00, 0x00, 0x3f, 0x00,
|
||||
]);
|
||||
const eoi = new Uint8Array([0xff, 0xd9]);
|
||||
return new Uint8Array([...soi, ...sos, ...eoi]);
|
||||
}
|
||||
|
||||
export function buildMinimalPng(): Uint8Array {
|
||||
const sig = new Uint8Array([
|
||||
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a,
|
||||
]);
|
||||
const ihdr = new Uint8Array(25);
|
||||
const dv = new DataView(ihdr.buffer);
|
||||
dv.setUint32(0, 13, false);
|
||||
ihdr[4] = 0x49;
|
||||
ihdr[5] = 0x48;
|
||||
ihdr[6] = 0x44;
|
||||
ihdr[7] = 0x52;
|
||||
dv.setUint32(8, 100, false);
|
||||
dv.setUint32(12, 80, false);
|
||||
ihdr[16] = 8;
|
||||
ihdr[17] = 2;
|
||||
return new Uint8Array([...sig, ...ihdr]);
|
||||
}
|
||||
|
||||
/** Pseudo-random bytes that match no known signature. */
|
||||
export function buildGibberish(): Uint8Array {
|
||||
return new Uint8Array([0x00, 0x01, 0x02, 0x03, 0x04, 0x05]);
|
||||
}
|
||||
Reference in New Issue
Block a user