diff options
author | 2015-01-12 18:14:35 -0800 | |
---|---|---|
committer | 2015-01-12 18:14:35 -0800 | |
commit | e5061519185627e58495bede780f757339ba07c5 (patch) | |
tree | 7bf63f4bcc35d2141351d8cf29fac7a6eb5dfe63 /src/node/test/byte_buffer_test.js~ | |
parent | 470a3ea1a192e53a61012c30a6a9a5efcc712948 (diff) |
Clean commit of Node.js library source
Diffstat (limited to 'src/node/test/byte_buffer_test.js~')
-rw-r--r-- | src/node/test/byte_buffer_test.js~ | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/node/test/byte_buffer_test.js~ b/src/node/test/byte_buffer_test.js~ new file mode 100644 index 0000000000..8f272e5bd6 --- /dev/null +++ b/src/node/test/byte_buffer_test.js~ @@ -0,0 +1,35 @@ +var assert = require('assert'); +var grpc = require('..build/Release/grpc'); + +describe('byte buffer', function() { + describe('constructor', function() { + it('should reject bad constructor calls', function() { + it('should require at least one argument', function() { + assert.throws(new grpc.ByteBuffer(), TypeError); + }); + it('should reject non-string arguments', function() { + assert.throws(new grpc.ByteBuffer(0), TypeError); + assert.throws(new grpc.ByteBuffer(1.5), TypeError); + assert.throws(new grpc.ByteBuffer(null), TypeError); + assert.throws(new grpc.ByteBuffer(Date.now()), TypeError); + }); + it('should accept string arguments', function() { + assert.doesNotThrow(new grpc.ByteBuffer('')); + assert.doesNotThrow(new grpc.ByteBuffer('test')); + assert.doesNotThrow(new grpc.ByteBuffer('\0')); + }); + }); + }); + describe('bytes', function() { + it('should return the passed string', function() { + it('should preserve simple strings', function() { + var buffer = new grpc.ByteBuffer('test'); + assert.strictEqual(buffer.bytes(), 'test'); + }); + it('should preserve null characters', function() { + var buffer = new grpc.ByteBuffer('test\0test'); + assert.strictEqual(buffer.bytes(), 'test\0test'); + }); + }); + }); +}); |