mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-22 03:55:17 +08:00
# Conflicts: # jsowell-ui/.env.development # jsowell-ui/.env.staging # jsowell-ui/bin/build-sit.bat # jsowell-ui/bin/build.bat # jsowell-ui/src/api/adapayMember/adapayMember.js # jsowell-ui/src/api/pile/merchant.js # jsowell-ui/src/router/index.js # jsowell-ui/src/views/financial/financeDetail.vue # jsowell-ui/src/views/financial/merchant.vue # jsowell-ui/src/views/homeIndex/homeIndex.vue # jsowell-ui/src/views/login.vue # jsowell-ui/src/views/pile/basic/detail.vue # jsowell-ui/src/views/pile/station/components/SiteInfo.vue # jsowell-ui/src/views/pile/station/detail.vue # jsowell-ui/src/views/pile/station/orderReport.vue
41 lines
1.1 KiB
JavaScript
41 lines
1.1 KiB
JavaScript
'use strict';
|
|
var Buffer = require('../../').Buffer;
|
|
|
|
|
|
var assert = require('assert');
|
|
|
|
var zero = [];
|
|
var one = [ Buffer.from('asdf') ];
|
|
var long = [];
|
|
for (var i = 0; i < 10; i++) long.push(Buffer.from('asdf'));
|
|
|
|
var flatZero = Buffer.concat(zero);
|
|
var flatOne = Buffer.concat(one);
|
|
var flatLong = Buffer.concat(long);
|
|
var flatLongLen = Buffer.concat(long, 40);
|
|
|
|
assert(flatZero.length === 0);
|
|
assert(flatOne.toString() === 'asdf');
|
|
// A special case where concat used to return the first item,
|
|
// if the length is one. This check is to make sure that we don't do that.
|
|
assert(flatOne !== one[0]);
|
|
assert(flatLong.toString() === (new Array(10 + 1).join('asdf')));
|
|
assert(flatLongLen.toString() === (new Array(10 + 1).join('asdf')));
|
|
|
|
assertWrongList();
|
|
assertWrongList(null);
|
|
assertWrongList(Buffer.from('hello'));
|
|
assertWrongList([42]);
|
|
assertWrongList(['hello', 'world']);
|
|
assertWrongList(['hello', Buffer.from('world')]);
|
|
|
|
function assertWrongList(value) {
|
|
assert.throws(function() {
|
|
Buffer.concat(value);
|
|
}, function(err) {
|
|
return err instanceof TypeError &&
|
|
err.message === '"list" argument must be an Array of Buffers';
|
|
});
|
|
}
|
|
|