UNPKG

2.04 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3// *****************************************************************************
4// Copyright (C) 2021 Red Hat, Inc. and others.
5//
6// This program and the accompanying materials are made available under the
7// terms of the Eclipse Public License v. 2.0 which is available at
8// http://www.eclipse.org/legal/epl-2.0.
9//
10// This Source Code may also be made available under the following Secondary
11// Licenses when the conditions for such availability set forth in the Eclipse
12// Public License v. 2.0 are satisfied: GNU General Public License, version 2
13// with the GNU Classpath Exception which is available at
14// https://www.gnu.org/software/classpath/license.html.
15//
16// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
17// *****************************************************************************
18const chai_1 = require("chai");
19const uint8_array_message_buffer_1 = require("./uint8-array-message-buffer");
20describe('array message buffer tests', () => {
21 it('basic read write test', () => {
22 const buffer = new Uint8Array(1024);
23 const writer = new uint8_array_message_buffer_1.Uint8ArrayWriteBuffer(buffer);
24 writer.writeUint8(8);
25 writer.writeUint32(10000);
26 writer.writeBytes(new Uint8Array([1, 2, 3, 4]));
27 writer.writeString('this is a string');
28 writer.writeString('another string');
29 writer.commit();
30 const written = writer.getCurrentContents();
31 const reader = new uint8_array_message_buffer_1.Uint8ArrayReadBuffer(written);
32 (0, chai_1.expect)(reader.readUint8()).equal(8);
33 (0, chai_1.expect)(reader.readUint32()).equal(10000);
34 (0, chai_1.expect)(reader.readBytes()).deep.equal(new Uint8Array([1, 2, 3, 4]));
35 (0, chai_1.expect)(reader.readString()).equal('this is a string');
36 (0, chai_1.expect)(reader.readString()).equal('another string');
37 });
38});
39//# sourceMappingURL=uint8-array-message-buffer.spec.js.map
\No newline at end of file