source: trip-planner-front/node_modules/hdr-histogram-js/dist/packedarray/PackedArray.fc.spec.js@ 571e0df

Last change on this file since 571e0df was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.5 KB
RevLine 
[6a3a178]1"use strict";
2Object.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 */
10const fc = require("fast-check");
11const PackedArray_1 = require("./PackedArray");
12const runFromStryker = __dirname.includes("stryker");
13const runnerOptions = {
14 numRuns: runFromStryker ? 10 : 1000,
15 verbose: true
16};
17describe("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});
36const arbData = (size) => fc.array(fc.tuple(fc.integer(1, size), fc.integer(1, 100000000)), 1, size);
37//# sourceMappingURL=PackedArray.fc.spec.js.map
Note: See TracBrowser for help on using the repository browser.