Skip to content

Commit 1677a7b

Browse files
committed
Added tests for NaN/Infinity
1 parent d709238 commit 1677a7b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tests/suite.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,18 @@ var suite = {
788788
}
789789
test.done();
790790
},
791+
792+
"NaN": function(test) {
793+
var bb = new ByteBuffer(4);
794+
test.ok(isNaN(bb.writeFloat(NaN).flip().readFloat(0)));
795+
test.strictEqual(bb.writeFloat(+Infinity).flip().readFloat(0), +Infinity);
796+
test.strictEqual(bb.writeFloat(-Infinity).flip().readFloat(0), -Infinity);
797+
bb.resize(8);
798+
test.ok(isNaN(bb.writeDouble(NaN).flip().readDouble(0)));
799+
test.strictEqual(bb.writeDouble(+Infinity).flip().readDouble(0), +Infinity);
800+
test.strictEqual(bb.writeDouble(-Infinity).flip().readDouble(0), -Infinity);
801+
test.done();
802+
},
791803

792804
"commonjs": function(test) {
793805
var fs = require("fs")

0 commit comments

Comments
 (0)