[6a3a178] | 1 | "use strict";
|
---|
| 2 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
| 3 | /*
|
---|
| 4 | * This is a TypeScript port of the original Java version, which was written by
|
---|
| 5 | * Gil Tene as described in
|
---|
| 6 | * https://github.com/HdrHistogram/HdrHistogram
|
---|
| 7 | * and released to the public domain, as explained at
|
---|
| 8 | * http://creativecommons.org/publicdomain/zero/1.0/
|
---|
| 9 | */
|
---|
| 10 | const fc = require("fast-check");
|
---|
| 11 | const PackedArray_1 = require("./PackedArray");
|
---|
| 12 | const runFromStryker = __dirname.includes("stryker");
|
---|
| 13 | const runnerOptions = {
|
---|
| 14 | numRuns: runFromStryker ? 10 : 1000,
|
---|
| 15 | verbose: true
|
---|
| 16 | };
|
---|
| 17 | describe("Packed array", () => {
|
---|
| 18 | it("should store data as a regular sparse array", () => {
|
---|
| 19 | const SIZE = 1000;
|
---|
| 20 | fc.assert(fc.property(arbData(SIZE), entries => {
|
---|
| 21 | const packedArray = new PackedArray_1.PackedArray(SIZE + 1);
|
---|
| 22 | const sparseArray = new Array();
|
---|
| 23 | entries.forEach(([index, value]) => packedArray.add(index, value));
|
---|
| 24 | entries.forEach(([index, value]) => {
|
---|
| 25 | if (sparseArray[index]) {
|
---|
| 26 | sparseArray[index] = sparseArray[index] + value;
|
---|
| 27 | }
|
---|
| 28 | else {
|
---|
| 29 | sparseArray[index] = value;
|
---|
| 30 | }
|
---|
| 31 | });
|
---|
| 32 | return entries.every(([index]) => sparseArray[index] === packedArray.get(index));
|
---|
| 33 | }), runnerOptions);
|
---|
| 34 | });
|
---|
| 35 | });
|
---|
| 36 | const arbData = (size) => fc.array(fc.tuple(fc.integer(1, size), fc.integer(1, 100000000)), 1, size);
|
---|
| 37 | //# sourceMappingURL=PackedArray.fc.spec.js.map |
---|