source: trip-planner-front/node_modules/hdr-histogram-js/assembly/__tests__/PackedArray.spec.ts@ b738035

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

initial commit

  • Property mode set to 100644
File size: 1.1 KB
Line 
1/*
2 * This is a AssemblyScript port of the original Java version, which was written by
3 * Gil Tene as described in
4 * https://github.com/HdrHistogram/HdrHistogram
5 * and released to the public domain, as explained at
6 * http://creativecommons.org/publicdomain/zero/1.0/
7 */
8
9import { PackedArray } from "../packedarray/PackedArray";
10
11describe("Packed Array", () => {
12 it("should store a byte without extending array", () => {
13 // given
14 const packed = new PackedArray(1024);
15 // when
16 packed.set(42, 123);
17 // then
18 expect(packed.get(42)).toBe(123);
19 });
20
21 it("should resize array when storing data", () => {
22 // given
23 const array = new PackedArray(1024, 16);
24
25 // when
26 array.set(12, u64.MAX_VALUE);
27
28 // then
29 const storedData = array.get(12);
30 expect(storedData).toBe(u64.MAX_VALUE);
31 });
32 it("should store a big number", () => {
33 // given
34 const array = new PackedArray(45056, 16);
35
36 // when
37 array.set(32768, 1);
38
39 // then
40 const storedData = array.get(32768);
41 expect(storedData).toBe(1);
42 const storedDataAt0 = array.get(0);
43 expect(storedDataAt0).toBe(0);
44 });
45});
Note: See TracBrowser for help on using the repository browser.