Fix javascript unicode test

The generated buffer should be tested for semantic equivalence
to the correct buffer, instead of being tested for bytewise
equality.
This commit is contained in:
Robert Nix 2016-02-12 12:12:54 -06:00
parent d2bc73bbbe
commit 2f5d7ae645
1 changed files with 18 additions and 16 deletions

View File

@ -122,7 +122,7 @@ function testUnicode() {
var json = JSON.parse(fs.readFileSync('unicode_test.json', 'utf8'));
// Test reading
var bb = new flatbuffers.ByteBuffer(new Uint8Array(correct));
function testReadingUnicode(bb) {
var monster = MyGame.Example.Monster.getRootAsMonster(bb);
assert.strictEqual(monster.name(), json.name);
assert.deepEqual(new Buffer(monster.name(flatbuffers.Encoding.UTF8_BYTES)), new Buffer(json.name));
@ -137,6 +137,8 @@ function testUnicode() {
assert.strictEqual(monster.testarrayofstring(i), string);
assert.deepEqual(new Buffer(monster.testarrayofstring(i, flatbuffers.Encoding.UTF8_BYTES)), new Buffer(string));
});
}
testReadingUnicode(new flatbuffers.ByteBuffer(new Uint8Array(correct)));
// Test writing
var fbb = new flatbuffers.Builder();
@ -156,7 +158,7 @@ function testUnicode() {
MyGame.Example.Monster.addTestarrayoftables(fbb, testarrayoftablesOffset);
MyGame.Example.Monster.addName(fbb, name);
MyGame.Example.Monster.finishMonsterBuffer(fbb, MyGame.Example.Monster.endMonster(fbb));
assert.deepEqual(new Buffer(fbb.asUint8Array()), correct);
testReadingUnicode(new flatbuffers.ByteBuffer(fbb.asUint8Array()));
}
var __imul = Math.imul ? Math.imul : function(a, b) {