Permalink
Browse files

Add UTF-8 tests for parser and writer

  • Loading branch information...
1 parent b3d472c commit cabd248c5c4e7df12c11d9e830691157018988ec @codeaholics committed Aug 5, 2013
Showing with 38 additions and 1 deletion.
  1. BIN test/dumps/utf8.rdb
  2. +7 −0 test/parser.js
  3. +31 −1 test/writer.js
View
Binary file not shown.
View
@@ -277,6 +277,13 @@ describe('Parser', function() {
done();
})
});
+
+ it('should handle UTF-8', function(done) {
+ load('utf8.rdb', function(data) {
+ assert.equal(data.allKeys[0]['\u00A3'].value, '\u00A9');
+ done();
+ })
+ });
})
function load(database, cb, errback) {
View
@@ -18,6 +18,7 @@ var Parser = require('../rdb-tools').Parser,
fs = require('fs'),
Writable = require('stream').Writable,
Transform = require('stream').Transform,
+ BufferList = require('bl'),
_ = require('underscore');
describe('Writer', function() {
@@ -45,7 +46,36 @@ describe('Writer', function() {
});
});
- it.skip('should handle UTF-8');
+ it('should handle UTF-8', function(done) {
+ var writer = new Writer(),
+ bl = new BufferList(function(err, data) {
+ assert.equal(data.get(13), 0xC2);
+ assert.equal(data.get(14), 0xA3);
+ assert.equal(data.get(16), 0xC2);
+ assert.equal(data.get(17), 0xA9);
+ done();
+ });
+
+ writer.pipe(bl);
+
+ writer.write({
+ type: 'header',
+ version: 6
+ });
+
+ writer.write({
+ type: 'database',
+ number: 0
+ });
+
+ writer.end({
+ type: 'key',
+ rtype: 'string',
+ database: 0,
+ key: '\u00A3',
+ value: '\u00A9'
+ });
+ });
});
function simpleErrorTest(obj, done) {

0 comments on commit cabd248

Please sign in to comment.