deno.land / std@0.166.0 / node / _tools / test / parallel / test-buffer-equals.js

test-buffer-equals.js
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// deno-fmt-ignore-file// deno-lint-ignore-file
// Copyright Joyent and Node contributors. All rights reserved. MIT license.// Taken from Node 18.12.0// This file is automatically generated by "node/_tools/setup.ts". Do not modify this file manually
'use strict';
require('../common');const assert = require('assert');
const b = Buffer.from('abcdf');const c = Buffer.from('abcdf');const d = Buffer.from('abcde');const e = Buffer.from('abcdef');
assert.ok(b.equals(c));assert.ok(!c.equals(d));assert.ok(!d.equals(e));assert.ok(d.equals(d));assert.ok(d.equals(new Uint8Array([0x61, 0x62, 0x63, 0x64, 0x65])));
assert.throws( () => Buffer.alloc(1).equals('abc'), { code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError', message: 'The "otherBuffer" argument must be an instance of ' + "Buffer or Uint8Array. Received type string ('abc')" });
std

Version Info

Tagged at
a year ago