aboutsummaryrefslogtreecommitdiff
path: root/test/bun.js/buffer.test.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/bun.js/buffer.test.js')
-rw-r--r--test/bun.js/buffer.test.js82
1 files changed, 41 insertions, 41 deletions
diff --git a/test/bun.js/buffer.test.js b/test/bun.js/buffer.test.js
index 47cdbe210..c3f422024 100644
--- a/test/bun.js/buffer.test.js
+++ b/test/bun.js/buffer.test.js
@@ -222,7 +222,7 @@ it("Buffer.copy", () => {
{
// Create two `Buffer` instances.
const buf1 = Buffer.allocUnsafe(26);
- const buf2 = Buffer.allocUnsafe(26).fill('!');
+ const buf2 = Buffer.allocUnsafe(26).fill("!");
for (let i = 0; i < 26; i++) {
// 97 is the decimal ASCII value for 'a'.
@@ -231,7 +231,7 @@ it("Buffer.copy", () => {
// Copy `buf1` bytes 16 through 19 into `buf2` starting at byte 8 of `buf2`.
buf1.copy(buf2, 8, 16, 20);
- expect(buf2.toString('ascii', 0, 25)).toBe('!!!!!!!!qrst!!!!!!!!!!!!!');
+ expect(buf2.toString("ascii", 0, 25)).toBe("!!!!!!!!qrst!!!!!!!!!!!!!");
}
{
@@ -243,7 +243,7 @@ it("Buffer.copy", () => {
}
buf.copy(buf, 0, 4, 10);
- expect(buf.toString()).toBe('efghijghijklmnopqrstuvwxyz');
+ expect(buf.toString()).toBe("efghijghijklmnopqrstuvwxyz");
}
});
@@ -427,33 +427,33 @@ it("write", () => {
});
it("includes", () => {
- const buf = Buffer.from('this is a buffer');
+ const buf = Buffer.from("this is a buffer");
- expect(buf.includes('this')).toBe(true);
- expect(buf.includes('is')).toBe(true);
- expect(buf.includes(Buffer.from('a buffer'))).toBe(true);
+ expect(buf.includes("this")).toBe(true);
+ expect(buf.includes("is")).toBe(true);
+ expect(buf.includes(Buffer.from("a buffer"))).toBe(true);
expect(buf.includes(97)).toBe(true);
- expect(buf.includes(Buffer.from('a buffer example'))).toBe(false);
- expect(buf.includes(Buffer.from('a buffer example').slice(0, 8))).toBe(true);
- expect(buf.includes('this', 4)).toBe(false);
+ expect(buf.includes(Buffer.from("a buffer example"))).toBe(false);
+ expect(buf.includes(Buffer.from("a buffer example").slice(0, 8))).toBe(true);
+ expect(buf.includes("this", 4)).toBe(false);
});
it("indexOf", () => {
- const buf = Buffer.from('this is a buffer');
+ const buf = Buffer.from("this is a buffer");
- expect(buf.indexOf('this')).toBe(0);
- expect(buf.indexOf('is')).toBe(2);
- expect(buf.indexOf(Buffer.from('a buffer'))).toBe(8);
+ expect(buf.indexOf("this")).toBe(0);
+ expect(buf.indexOf("is")).toBe(2);
+ expect(buf.indexOf(Buffer.from("a buffer"))).toBe(8);
expect(buf.indexOf(97)).toBe(8);
- expect(buf.indexOf(Buffer.from('a buffer example'))).toBe(-1);
- expect(buf.indexOf(Buffer.from('a buffer example').slice(0, 8))).toBe(8);
+ expect(buf.indexOf(Buffer.from("a buffer example"))).toBe(-1);
+ expect(buf.indexOf(Buffer.from("a buffer example").slice(0, 8))).toBe(8);
- const utf16Buffer = Buffer.from('\u039a\u0391\u03a3\u03a3\u0395', 'utf16le');
+ const utf16Buffer = Buffer.from("\u039a\u0391\u03a3\u03a3\u0395", "utf16le");
- expect(utf16Buffer.indexOf('\u03a3', 0, 'utf16le')).toBe(4);
- expect(utf16Buffer.indexOf('\u03a3', -4, 'utf16le')).toBe(6);
+ expect(utf16Buffer.indexOf("\u03a3", 0, "utf16le")).toBe(4);
+ expect(utf16Buffer.indexOf("\u03a3", -4, "utf16le")).toBe(6);
- const b = Buffer.from('abcdef');
+ const b = Buffer.from("abcdef");
// Passing a value that's a number, but not a valid byte.
// Prints: 2, equivalent to searching for 99 or 'c'.
@@ -462,31 +462,31 @@ it("indexOf", () => {
// Passing a byteOffset that coerces to NaN or 0.
// Prints: 1, searching the whole buffer.
- expect(b.indexOf('b', undefined)).toBe(1);
- expect(b.indexOf('b', {})).toBe(1);
- expect(b.indexOf('b', null)).toBe(1);
- expect(b.indexOf('b', [])).toBe(1);
+ expect(b.indexOf("b", undefined)).toBe(1);
+ expect(b.indexOf("b", {})).toBe(1);
+ expect(b.indexOf("b", null)).toBe(1);
+ expect(b.indexOf("b", [])).toBe(1);
});
it("lastIndexOf", () => {
- const buf = Buffer.from('this buffer is a buffer');
+ const buf = Buffer.from("this buffer is a buffer");
- expect(buf.lastIndexOf('this')).toBe(0);
- expect(buf.lastIndexOf('this', 0)).toBe(0);
- expect(buf.lastIndexOf('this', -1000)).toBe(-1);
- expect(buf.lastIndexOf('buffer')).toBe(17);
- expect(buf.lastIndexOf(Buffer.from('buffer'))).toBe(17);
+ expect(buf.lastIndexOf("this")).toBe(0);
+ expect(buf.lastIndexOf("this", 0)).toBe(0);
+ expect(buf.lastIndexOf("this", -1000)).toBe(-1);
+ expect(buf.lastIndexOf("buffer")).toBe(17);
+ expect(buf.lastIndexOf(Buffer.from("buffer"))).toBe(17);
expect(buf.lastIndexOf(97)).toBe(15);
- expect(buf.lastIndexOf(Buffer.from('yolo'))).toBe(-1);
- expect(buf.lastIndexOf('buffer', 5)).toBe(5);
- expect(buf.lastIndexOf('buffer', 4)).toBe(-1);
+ expect(buf.lastIndexOf(Buffer.from("yolo"))).toBe(-1);
+ expect(buf.lastIndexOf("buffer", 5)).toBe(5);
+ expect(buf.lastIndexOf("buffer", 4)).toBe(-1);
- const utf16Buffer = Buffer.from('\u039a\u0391\u03a3\u03a3\u0395', 'utf16le');
+ const utf16Buffer = Buffer.from("\u039a\u0391\u03a3\u03a3\u0395", "utf16le");
- expect(utf16Buffer.lastIndexOf('\u03a3', undefined, 'utf16le')).toBe(6);
- expect(utf16Buffer.lastIndexOf('\u03a3', -5, 'utf16le')).toBe(4);
+ expect(utf16Buffer.lastIndexOf("\u03a3", undefined, "utf16le")).toBe(6);
+ expect(utf16Buffer.lastIndexOf("\u03a3", -5, "utf16le")).toBe(4);
- const b = Buffer.from('abcdef');
+ const b = Buffer.from("abcdef");
// Passing a value that's a number, but not a valid byte.
// Prints: 2, equivalent to searching for 99 or 'c'.
@@ -495,11 +495,11 @@ it("lastIndexOf", () => {
// Passing a byteOffset that coerces to NaN or 0.
// Prints: 1, searching the whole buffer.
- expect(b.lastIndexOf('b', undefined)).toBe(1);
- expect(b.lastIndexOf('b', {})).toBe(1);
+ expect(b.lastIndexOf("b", undefined)).toBe(1);
+ expect(b.lastIndexOf("b", {})).toBe(1);
// Passing a byteOffset that coerces to 0.
// Prints: -1, equivalent to passing 0.
- expect(b.lastIndexOf('b', null)).toBe(-1);
- expect(b.lastIndexOf('b', [])).toBe(-1);
+ expect(b.lastIndexOf("b", null)).toBe(-1);
+ expect(b.lastIndexOf("b", [])).toBe(-1);
});