Skip to content

Commit

Permalink
Add some string tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Nov 30, 2010
1 parent 236b2b6 commit 4179e93
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions test/simple/test-dumper.js
Expand Up @@ -4,9 +4,9 @@ var net = require('net');

var ncomplete = 0;

function test (N, size, cb) {
function test (N, b, cb) {
//console.trace();
var expected = N * size;
var expected = N * b.length;
var nread = 0;

// Create a pipe
Expand Down Expand Up @@ -51,10 +51,6 @@ function test (N, size, cb) {


// Create out single 1mb buffer.
var b = new Buffer(size);
for (var i = 0; i < size; i++) {
b[i] = 100;
}

// Fill the dumpQueue with N copies of that buffer.
var x = IOWatcher.dumpQueue;
Expand All @@ -77,21 +73,23 @@ function runTests (values) {
function go () {
if (ncomplete < values.length) {
var v = values[ncomplete];
console.log("go %j", v);
console.log("test N=%d, size=%d", v[0], v[1].length);
test(v[0], v[1], go);
}
}

go();
}

runTests([ [30, 1000]
, [4, 10000]
, [50, 1024*1024]
, [500, 40960+1]
, [500, 40960-1]
, [500, 40960]
, [500, 1024*1024+1]
runTests([ [30, Buffer(1000)]
, [4, Buffer(10000)]
, [1, "hello world\n"]
, [50, Buffer(1024*1024)]
, [500, Buffer(40960+1)]
, [500, Buffer(40960-1)]
, [500, Buffer(40960)]
, [500, Buffer(1024*1024+1)]
, [50000, "hello world\n"]
]);


Expand Down

0 comments on commit 4179e93

Please sign in to comment.