Files
reverse-engineering-anything/src/domain/peCoffHeader.test.ts
T
morluto 5044e20171 test: focus diagnostics and evidence checks on behavior (#9303)
* test: focus configuration diagnostics on their owners

Preserve shape errors, selected paths, recovery guidance, and unchanged-file behavior across parser, setup, and uninstall boundaries.

* test: focus artifact and evidence checks on behavior

Retain format, identity, malformed-input, and cleanup coverage while removing fixed prose and closing the admitted test source.

* refactor(debugger): use configured session admission limits

* test: focus evidence and diagnostics on behavior

* fix(test): restore verifier export and formatting

* test(config): verify debugger limit ranges

* test(rizin): keep fixture executable authoritative

* test(rizin): isolate debugger fixture environment
2026-11-08 16:39:20 +00:00

37 lines
1.1 KiB
TypeScript

import { expect, it } from "vitest";
import { readPeCoffHeader } from "./peCoffHeader.js";
it("retains raw COFF declarations from a borrowed record without admission policy", () => {
const source = Buffer.alloc(39, 0xa5);
const record = source.subarray(7, 27);
record.writeUInt16LE(0xffff, 0);
record.writeUInt16LE(0x1234, 2);
record.writeUInt16LE(0xfedc, 16);
record.writeUInt16LE(0x89ab, 18);
const before = Buffer.from(source);
expect(readPeCoffHeader(source.subarray(7))).toEqual({
ok: true,
value: {
machine: 0xffff,
sectionCount: 0x1234,
optionalHeaderSize: 0xfedc,
characteristics: 0x89ab,
},
});
expect(source.equals(before)).toBe(true);
});
it.each(Array.from({ length: 20 }, (_, length) => length))(
"reports a truncated %i-byte COFF record without reading outside it",
(length) => {
const source = Buffer.alloc(40, 0xff);
expect(readPeCoffHeader(source.subarray(7, 7 + length))).toEqual({
ok: false,
error: {
kind: "malformed",
message: expect.stringContaining("truncated"),
},
});
},
);