1
0
Fork 0

Adding upstream version 0.0~git20250409.f7acab6.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-05-22 11:36:18 +02:00
parent b9b5d88025
commit 21b930d007
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
51 changed files with 11229 additions and 0 deletions

34
buffer/testdata/assertions.js vendored Normal file
View file

@ -0,0 +1,34 @@
/**
* Assertion helper functions for Buffer tests
*/
"use strict";
const assert = require("../../assert.js");
function assertValueRead(actual, expected) {
assert.sameValue(actual, expected, "value read does not match; ")
}
function assertBytesWritten(actual, expected) {
assert.sameValue(actual, expected, "bytesWritten does not match; ")
}
function assertBufferWriteRead(buffer, writeMethod, readMethod, value, offset = 0) {
const bytesWritten = buffer[writeMethod](value, offset);
const bytesPerElement = getBufferElementSize(writeMethod);
assertBytesWritten(bytesWritten, offset + bytesPerElement);
const readValue = buffer[readMethod](offset);
assertValueRead(readValue, value);
}
// getBufferElementSize determines the number of bytes per type based on method name
function getBufferElementSize(methodName) {
if (methodName.includes('64')) return 8;
if (methodName.includes('Double')) return 8;
if (methodName.includes('32')) return 4;
if (methodName.includes('Float')) return 4;
if (methodName.includes('16')) return 2;
if (methodName.includes('8')) return 1;
return 1;
}