33 lines
1002 B
TypeScript
33 lines
1002 B
TypeScript
import { describe, it } from "@suaveplan/testing/runner";
|
|
import fc from "fast-check";
|
|
import { computeChecksum } from "../src/runner/runner.js";
|
|
|
|
describe("property — SHA-256 checksum stability", () => {
|
|
it("identical content produces identical SHA-256", {
|
|
timeout: 30000,
|
|
}, () => {
|
|
fc.assert(
|
|
fc.property(fc.string(), (content) => {
|
|
const a = computeChecksum(content);
|
|
const b = computeChecksum(content);
|
|
return a === b && /^[0-9a-f]{64}$/.test(a);
|
|
})
|
|
);
|
|
});
|
|
|
|
it("different content produces different SHA-256", {
|
|
timeout: 30000,
|
|
}, () => {
|
|
fc.assert(
|
|
fc.property(
|
|
fc.string({ minLength: 1 }),
|
|
fc.string({ minLength: 1 }),
|
|
(a, b) => {
|
|
if (a === b) return true;
|
|
return computeChecksum(a) !== computeChecksum(b);
|
|
}
|
|
)
|
|
);
|
|
});
|
|
});
|