Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,23 @@ describe("Tree Representation tests", () => {
validate(2 + 5);
});

it("loads from a Uint8Array with a non-zero byte offset", () => {
builder.addString("first");
builder.addBlob(createLongBuffer(3));

const serialized = builder.serialize();
const backingBuffer = new Uint8Array(serialized.length + 2);
backingBuffer.set(serialized, 1);
const offsetBuffer = backingBuffer.subarray(1, serialized.length + 1);
assert.notStrictEqual(offsetBuffer.byteOffset, 0, "Test buffer should have a byte offset");

const builder2 = TreeBuilder.load(
new ReadBuffer(offsetBuffer),
logger.toTelemetryLogger(),
).builder;
compareNodes(builder, builder2);
});

it("small const string", async () => {
builder.addDictionaryString("first");
validate(8 + 2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,6 @@ export class NodeCore {

length = 0;
const input = buffer.buffer;
assert(input.byteOffset === 0, 0x3e8 /* code below assumes no offset */);
Comment thread
jason-ha marked this conversation as resolved.

for (const el of stringsToResolve) {
for (let it = el.startPos; it < el.endPos; it++) {
Expand Down
Loading