Skip to content

Commit

Permalink
Added test for empty strings
Browse files Browse the repository at this point in the history
  • Loading branch information
celer committed Jan 25, 2013
1 parent d35b892 commit 861778c
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions test/integration/test-empty-string.js
@@ -0,0 +1,39 @@
var common = require('../common');
var assert = common.assert;
var CombinedStream = common.CombinedStream;
var util = require('util');
var Stream = require('stream').Stream;

var s = CombinedStream.create();


function StringStream(){
this.writable=true;
this.str=""
}
util.inherits(StringStream,Stream);

StringStream.prototype.write=function(chunk,encoding){
this.str+=chunk.toString();
this.emit('data',chunk);
}

StringStream.prototype.end=function(chunk,encoding){
this.emit('end');
}

StringStream.prototype.toString=function(){
return this.str;
}


s.append("foo.");
s.append("");
s.append("bar");

var ss = new StringStream();

s.pipe(ss);
s.resume();

assert.equal(ss.toString(),"foo.bar");

0 comments on commit 861778c

Please sign in to comment.