You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

25 lines
721 B

import * as fc from "fast-check";
import ByteBuffer from "./ByteBuffer";
import ZigZagEncoding from "./ZigZagEncoding";
const runFromStryker = __dirname.includes("stryker");
const runnerOptions = {
numRuns: runFromStryker ? 10 : 1000,
};
describe("Zig Zag Encoding", () => {
it("should get the same number after an encoding & decoding", () => {
const buffer = ByteBuffer.allocate(8);
fc.assert(
fc.property(fc.nat(Number.MAX_SAFE_INTEGER), (number) => {
buffer.resetPosition();
ZigZagEncoding.encode(buffer, number);
buffer.resetPosition();
const result = ZigZagEncoding.decode(buffer);
return number === result;
}),
runnerOptions
);
});
});