Skip to content

Commit

Permalink
Extend non-ascii test to cover bytes 0-255
Browse files Browse the repository at this point in the history
  • Loading branch information
lrowe committed Jan 12, 2015
1 parent c99de80 commit 77dd2e6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 5 additions & 1 deletion test/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ var routes = {
},
'/nonascii': function(res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end(new Buffer([200, 201]));
var buf = new Buffer(256);
for (var i = 0; i< 256; i++) {
buf[i] = i;
}
res.end(buf);
},
'/redirect/301': function(res) {
res.writeHead(301, {'Location': '/hello'});
Expand Down
8 changes: 6 additions & 2 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ suite('Body mixin', function() {
return response.arrayBuffer()
}).then(function(buf) {
assert(buf instanceof ArrayBuffer, 'buf is an ArrayBuffer instance')
assert.equal(buf.byteLength, 2, 'blob.size is correct')
assert.equal(buf.byteLength, 256, 'buf.byteLength is correct')
var view = new Uint8Array(buf)
for (var i = 0; i< 256; i++) {
assert.equal(view[i], i)
}
})
})

Expand Down Expand Up @@ -108,7 +112,7 @@ suite('Body mixin', function() {
return response.blob()
}).then(function(blob) {
assert(blob instanceof Blob, 'blob is a Blob instance')
assert.equal(blob.size, 2, 'blob.size is correct')
assert.equal(blob.size, 256, 'blob.size is correct')
})
})

Expand Down

0 comments on commit 77dd2e6

Please sign in to comment.