mirror of
https://github.com/siemens-mobile-hacks/node-serialport-bindings-cpp.git
synced 2026-11-26 02:47:17 +00:00
Fix comparison operators
This commit is contained in:
parent
772492aa3d
commit
d01e9a2ea1
2 changed files with 8 additions and 8 deletions
|
|
@ -51,9 +51,9 @@ module.exports = {
|
|||
return function (emitter, buffer) {
|
||||
for (var i = 0; i < buffer.length; i++) {
|
||||
buf[buf.length] = buffer[i];
|
||||
if(buf[buf.length-1] == delimiter[nextDelimIndex])
|
||||
if(buf[buf.length-1] === delimiter[nextDelimIndex])
|
||||
nextDelimIndex++;
|
||||
if(nextDelimIndex == delimiter.length) {
|
||||
if(nextDelimIndex === delimiter.length) {
|
||||
emitter.emit('data', buf);
|
||||
buf = [];
|
||||
nextDelimIndex = 0;
|
||||
|
|
|
|||
|
|
@ -52,11 +52,11 @@ describe('parsers', function () {
|
|||
parser({ emit: spy }, data);
|
||||
expect(spy.callCount).to.equal(3);
|
||||
expect(spy.getCall(0).args[1]).to.have.length(15);
|
||||
expect(spy.getCall(0).args[1]).to.satisfy(function(d) { return d[d.length-1] == 0; });
|
||||
expect(spy.getCall(0).args[1]).to.satisfy(function(d) { return d[d.length-1] === 0; });
|
||||
expect(spy.getCall(1).args[1]).to.have.length(13);
|
||||
expect(spy.getCall(1).args[1]).to.satisfy(function(d) { return d[d.length-1] == 0; });
|
||||
expect(spy.getCall(1).args[1]).to.satisfy(function(d) { return d[d.length-1] === 0; });
|
||||
expect(spy.getCall(2).args[1]).to.have.length(21);
|
||||
expect(spy.getCall(2).args[1]).to.satisfy(function(d) { return d[d.length-1] == 0; });
|
||||
expect(spy.getCall(2).args[1]).to.satisfy(function(d) { return d[d.length-1] === 0; });
|
||||
});
|
||||
it('accepts single byte delimiter', function() {
|
||||
var data = new Buffer('This could be\0binary data\0sent from a Moteino\0');
|
||||
|
|
@ -81,11 +81,11 @@ describe('parsers', function () {
|
|||
parser({ emit: spy }, data2);
|
||||
expect(spy.callCount).to.equal(3);
|
||||
expect(spy.getCall(0).args[1]).to.have.length(15);
|
||||
expect(spy.getCall(0).args[1]).to.satisfy(function(d) { return d[d.length-1] == 0; });
|
||||
expect(spy.getCall(0).args[1]).to.satisfy(function(d) { return d[d.length-1] === 0; });
|
||||
expect(spy.getCall(1).args[1]).to.have.length(13);
|
||||
expect(spy.getCall(1).args[1]).to.satisfy(function(d) { return d[d.length-1] == 0; });
|
||||
expect(spy.getCall(1).args[1]).to.satisfy(function(d) { return d[d.length-1] === 0; });
|
||||
expect(spy.getCall(2).args[1]).to.have.length(21);
|
||||
expect(spy.getCall(2).args[1]).to.satisfy(function(d) { return d[d.length-1] == 0; });
|
||||
expect(spy.getCall(2).args[1]).to.satisfy(function(d) { return d[d.length-1] === 0; });
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue