added failing test for reading empty row

This commit is contained in:
brianc 2010-10-01 00:22:53 -05:00
parent 8fe24a31a9
commit 961f3f1984
2 changed files with 19 additions and 10 deletions

View File

@ -3,7 +3,7 @@ var sys = require('sys');
var net = require('net');
var NUL = '\0';
var chars = Buffer('RSKZQCT','utf8');
var chars = Buffer('RSKZQCTD','utf8');
var UTF8 = {
R: chars[0],
S: chars[1],
@ -11,7 +11,8 @@ var UTF8 = {
Z: chars[3],
Q: chars[4],
C: chars[5],
T: chars[6]
T: chars[6],
D: chars[7]
};
@ -128,6 +129,8 @@ p.parseMessage = function() {
return this.parseC();
case UTF8.T:
return this.parseT();
case UTF8.D:
return this.parseD();
default:
throw new Error("Unsupported message ID: " + Buffer([messageID]).toString('utf8') + " (" + messageID.toString(16) + ")");
}
@ -210,6 +213,11 @@ p.parseField = function() {
return row;
};
p.parseD = function() {
var msg = this.parseStart('DataRow');
msg.fieldCount = this.readInt16();
};
p.readInt32 = function() {
var buffer = this.buffer;
return ((buffer[this.offset++] << 24) +

View File

@ -178,14 +178,15 @@ test('Parser on single messages', function() {
});
// test('parses raw data row buffers', function() {
// var emptyRow = new BufferList()
// .addInt16(0)
// .join(true, 'D');
// test('parses empty data row', function() {
// var result = PARSE(emptyRow)[0];
// });
// });
test('parses raw data row buffers', function() {
var emptyRow = new BufferList()
.addInt16(0)
.join(true, 'D');
test('parses empty data row', function() {
var result = PARSE(emptyRow)[0];
assert.equal(result.columnCount, 0);
});
});
test('parsing empty buffer returns false', function() {