Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various fixes: typo, deps, tests #30

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
"test": "tap ./test/*.js"
},
"dependencies": {
"buffercursor": ">= 0.0.12",
"ipaddr.js": ">= 0.1.1"
"buffercursor": "0.0.12",
"ipaddr.js": "^1.1.0"
},
"devDependencies": {
"tap": ">= 0.4.3"
"tap": "^5.4.2"
}
}
2 changes: 1 addition & 1 deletion packet.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ function writeQuestion(buff, val, label_index) {
assert(val, 'Packet requires a question');
assertUndefined(val.name, 'Question requires a "name"');
assertUndefined(val.type, 'Question requires a "type"');
assertUndefined(val.class, 'Questionn requires a "class"');
assertUndefined(val.class, 'Question requires a "class"');
namePack(val.name, buff, label_index);
buff.writeUInt16BE(val.type & 0xFFFF);
buff.writeUInt16BE(val.class & 0xFFFF);
Expand Down
2 changes: 1 addition & 1 deletion test/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ files.forEach(function (file) {
var js = 'foo = ' + fs.readFileSync(jsFile, 'utf8');
js = vm.runInThisContext(js, jsFile);
var ret = Packet.parse(bin);
t.equivalent(ret, js);
t.same(ret, js, 'parsed packet equals fixture');
t.end();
});
});
8 changes: 4 additions & 4 deletions test/write.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ var fixtureDir = path.join(__dirname, 'fixtures');
var files = fs.readdirSync(fixtureDir).filter(function (f) { return /\.js$/.test(f); });

files.forEach(function (file) {
test('can parse ' + file, function (t) {
test('can write ' + file, function (t) {
var js = 'foo = ' + fs.readFileSync(path.join(fixtureDir, file), 'utf8');
js = vm.runInThisContext(js, file);
var buff = new Buffer(4096);
var written = Packet.write(buff, js);
var binFile = path.join(fixtureDir, file.replace(/\.js$/, '.bin'));
var bin = fs.readFileSync(binFile);
var rtrip = Packet.parse(buff.slice(0, written));
t.equivalent(written, bin.length, null, {testMsgLen: file});
t.equivalent(buff.slice(0, written), bin, null, {testBin: file});
t.equivalent(rtrip, js, null, {testObj: file});
t.same(written, bin.length, 'output is of equal size to fixture');
t.same(buff.slice(0, written), bin, 'output is equal to fixture');
t.same(rtrip, js, 'reparsed output is equal to fixture');
t.end();
});
});