diff --git a/test/test-helper.js b/test/test-helper.js index 355c0cad..25276113 100644 --- a/test/test-helper.js +++ b/test/test-helper.js @@ -34,7 +34,8 @@ stringToHex = function(string) { hexToString = function(hexArray) { return new Buffer(hexArray).toString('utf8'); } -var BufferList = function() { + +BufferList = function() { this.buffers = []; }; @@ -84,3 +85,11 @@ BufferList.prototype.join = function(appendLength, char) { }); return result; }; + +BufferList.concat = function() { + var total = new BufferList(); + for(var i = 0; i < arguments.length; i++) { + total.add(arguments[i]); + } + return total.join(); +}; diff --git a/test/writer-tests.js b/test/writer-tests.js index 93312fda..e69aeb40 100644 --- a/test/writer-tests.js +++ b/test/writer-tests.js @@ -63,3 +63,10 @@ test('does complicated buffer', function() { .join(true,'!'); assert.equalBuffers(buf, [33, 0, 0, 0, 0x0c, 0, 0, 0, 1, 0, 2, 33, 0]); }); + +test('concats', function() { + var buf1 = new BufferList().addInt32(8).join(false,'!'); + var buf2 = new BufferList().addInt16(1).join(); + var result = BufferList.concat(buf1, buf2); + assert.equalBuffers(result, [33, 0, 0, 0, 8, 0, 1]); +});