Last change
on this file since 1ad8e64 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
721 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | import * as fc from "fast-check";
|
---|
| 2 | import ByteBuffer from "./ByteBuffer";
|
---|
| 3 | import ZigZagEncoding from "./ZigZagEncoding";
|
---|
| 4 |
|
---|
| 5 | const runFromStryker = __dirname.includes("stryker");
|
---|
| 6 |
|
---|
| 7 | const runnerOptions = {
|
---|
| 8 | numRuns: runFromStryker ? 10 : 1000,
|
---|
| 9 | };
|
---|
| 10 |
|
---|
| 11 | describe("Zig Zag Encoding", () => {
|
---|
| 12 | it("should get the same number after an encoding & decoding", () => {
|
---|
| 13 | const buffer = ByteBuffer.allocate(8);
|
---|
| 14 | fc.assert(
|
---|
| 15 | fc.property(fc.nat(Number.MAX_SAFE_INTEGER), (number) => {
|
---|
| 16 | buffer.resetPosition();
|
---|
| 17 | ZigZagEncoding.encode(buffer, number);
|
---|
| 18 | buffer.resetPosition();
|
---|
| 19 | const result = ZigZagEncoding.decode(buffer);
|
---|
| 20 | return number === result;
|
---|
| 21 | }),
|
---|
| 22 | runnerOptions
|
---|
| 23 | );
|
---|
| 24 | });
|
---|
| 25 | });
|
---|
Note:
See
TracBrowser
for help on using the repository browser.