"use strict";
/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
Object.defineProperty(exports, "__esModule", { value: true });
const assert_1 = require("assert");
const textSegment_1 = require("../textSegment.cjs");
describe("segmentGroupCollection", () => {
    let segment;
    beforeEach(() => {
        segment = textSegment_1.TextSegment.make("abc");
    });
    it(".empty", () => {
        (0, assert_1.strict)(segment.segmentGroups.empty);
    });
    it(".size", () => {
        assert_1.strict.equal(segment.segmentGroups.size, 0);
    });
    it(".enqueue", () => {
        const segmentGroup = { segments: [], localSeq: 1, refSeq: 0 };
        segment.segmentGroups.enqueue(segmentGroup);
        (0, assert_1.strict)(!segment.segmentGroups.empty);
        assert_1.strict.equal(segment.segmentGroups.size, 1);
        assert_1.strict.equal(segmentGroup.segments.length, 1);
        assert_1.strict.equal(segmentGroup.segments[0], segment);
    });
    it(".dequeue", () => {
        const segmentGroup = { segments: [], localSeq: 1, refSeq: 0 };
        segment.segmentGroups.enqueue(segmentGroup);
        const segmentGroupCount = 6;
        while (segment.segmentGroups.size < segmentGroupCount) {
            segment.segmentGroups.enqueue({ segments: [], localSeq: 1, refSeq: 0 });
        }
        const dequeuedSegmentGroup = segment.segmentGroups.dequeue();
        assert_1.strict.equal(segment.segmentGroups.size, segmentGroupCount - 1);
        assert_1.strict.equal(dequeuedSegmentGroup?.segments.length, 1);
        assert_1.strict.equal(dequeuedSegmentGroup.segments[0], segment);
        assert_1.strict.equal(dequeuedSegmentGroup, segmentGroup);
    });
    it(".copyTo", () => {
        const segmentGroupCount = 6;
        while (segment.segmentGroups.size < segmentGroupCount) {
            segment.segmentGroups.enqueue({ segments: [], localSeq: 1, refSeq: 0 });
        }
        const segmentCopy = textSegment_1.TextSegment.make("");
        segment.segmentGroups.copyTo(segmentCopy);
        assert_1.strict.equal(segment.segmentGroups.size, segmentGroupCount);
        assert_1.strict.equal(segmentCopy.segmentGroups.size, segmentGroupCount);
        while (!segment.segmentGroups.empty || !segmentCopy.segmentGroups.empty) {
            const segmentGroup = segment.segmentGroups.dequeue();
            const copySegmentGroup = segmentCopy.segmentGroups.dequeue();
            assert_1.strict.equal(segmentGroup, copySegmentGroup);
            assert_1.strict.equal(segmentGroup?.segments.length, 2);
            assert_1.strict.equal(segmentGroup.segments[0], segment);
            assert_1.strict.equal(segmentGroup.segments[1], segmentCopy);
        }
    });
});
//# sourceMappingURL=segmentGroupCollection.spec.cjs.map