xref: /third_party/node/test/parallel/test-buffer-equals.js (revision 1cb0ef41)
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/parallel/
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_cirequire('../common');
41cb0ef41Sopenharmony_ciconst assert = require('assert');
51cb0ef41Sopenharmony_ci
61cb0ef41Sopenharmony_ciconst b = Buffer.from('abcdf');
71cb0ef41Sopenharmony_ciconst c = Buffer.from('abcdf');
81cb0ef41Sopenharmony_ciconst d = Buffer.from('abcde');
91cb0ef41Sopenharmony_ciconst e = Buffer.from('abcdef');
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ciassert.ok(b.equals(c));
121cb0ef41Sopenharmony_ciassert.ok(!c.equals(d));
131cb0ef41Sopenharmony_ciassert.ok(!d.equals(e));
141cb0ef41Sopenharmony_ciassert.ok(d.equals(d));
151cb0ef41Sopenharmony_ciassert.ok(d.equals(new Uint8Array([0x61, 0x62, 0x63, 0x64, 0x65])));
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_ciassert.throws(
181cb0ef41Sopenharmony_ci  () => Buffer.alloc(1).equals('abc'),
191cb0ef41Sopenharmony_ci  {
201cb0ef41Sopenharmony_ci    code: 'ERR_INVALID_ARG_TYPE',
211cb0ef41Sopenharmony_ci    name: 'TypeError',
221cb0ef41Sopenharmony_ci    message: 'The "otherBuffer" argument must be an instance of ' +
231cb0ef41Sopenharmony_ci             "Buffer or Uint8Array. Received type string ('abc')"
241cb0ef41Sopenharmony_ci  }
251cb0ef41Sopenharmony_ci);
26

Indexes created Thu Nov 07 10:32:03 CST 2024