1 | "use strict";
|
---|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
3 | const RecordedValuesIterator_1 = require("./RecordedValuesIterator");
|
---|
4 | const Int32Histogram_1 = require("./Int32Histogram");
|
---|
5 | describe("Recorded Values Iterator", () => {
|
---|
6 | it("should iterate to recorded value", () => {
|
---|
7 | // given
|
---|
8 | const histogram = new Int32Histogram_1.default(1, Number.MAX_SAFE_INTEGER, 2);
|
---|
9 | histogram.recordValue(123);
|
---|
10 | const iterator = new RecordedValuesIterator_1.default(histogram);
|
---|
11 | // when
|
---|
12 | const iterationValue = iterator.next();
|
---|
13 | // then
|
---|
14 | expect(iterator.hasNext()).toBe(false);
|
---|
15 | expect(iterationValue.totalCountToThisValue).toBe(1);
|
---|
16 | expect(iterationValue.totalValueToThisValue).toBe(123);
|
---|
17 | });
|
---|
18 | it("should iterate to all recorded values", () => {
|
---|
19 | // given
|
---|
20 | const histogram = new Int32Histogram_1.default(1, Number.MAX_SAFE_INTEGER, 2);
|
---|
21 | histogram.recordValue(1);
|
---|
22 | histogram.recordValue(300);
|
---|
23 | histogram.recordValue(3000);
|
---|
24 | const iterator = new RecordedValuesIterator_1.default(histogram);
|
---|
25 | // when
|
---|
26 | const values = [];
|
---|
27 | while (iterator.hasNext()) {
|
---|
28 | values.push(iterator.next().valueIteratedTo);
|
---|
29 | }
|
---|
30 | // then
|
---|
31 | expect(values).toHaveLength(3);
|
---|
32 | expect(values[0]).toBe(1);
|
---|
33 | expect(values[1]).toBeGreaterThan(300);
|
---|
34 | expect(values[2]).toBeGreaterThan(3000);
|
---|
35 | });
|
---|
36 | });
|
---|
37 | //# sourceMappingURL=RecordedValuesIterator.spec.js.map |
---|