mirror of https://github.com/grpc/grpc-node.git
36 lines
1.3 KiB
JavaScript
36 lines
1.3 KiB
JavaScript
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');
|
|
});
|
|
});
|
|
});
|
|
});
|