summaryrefslogtreecommitdiffstats
path: root/node_modules/buffer/test/write_infinity.js
diff options
context:
space:
mode:
authorGravatar Piotr Russ <mail@pruss.it> 2020-11-16 00:10:28 +0100
committerGravatar Piotr Russ <mail@pruss.it> 2020-11-16 00:10:28 +0100
commite06ec920f7a5d784e674c4c4b4e6d1da3dc7391d (patch)
tree55713f725f77b44ebfec86e4eec3ce33e71458ca /node_modules/buffer/test/write_infinity.js
downloadwebsite_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.tar.gz
website_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.tar.bz2
website_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.zip
api, login, auth
Diffstat (limited to 'node_modules/buffer/test/write_infinity.js')
-rw-r--r--node_modules/buffer/test/write_infinity.js45
1 files changed, 45 insertions, 0 deletions
diff --git a/node_modules/buffer/test/write_infinity.js b/node_modules/buffer/test/write_infinity.js
new file mode 100644
index 0000000..17d606a
--- /dev/null
+++ b/node_modules/buffer/test/write_infinity.js
@@ -0,0 +1,45 @@
+if (process.env.OBJECT_IMPL) global.TYPED_ARRAY_SUPPORT = false
+var B = require('../').Buffer
+var test = require('tape')
+
+test('write/read Infinity as a float', function (t) {
+ var buf = new B(4)
+ t.equal(buf.writeFloatBE(Infinity, 0), 4)
+ t.equal(buf.readFloatBE(0), Infinity)
+ t.end()
+})
+
+test('write/read -Infinity as a float', function (t) {
+ var buf = new B(4)
+ t.equal(buf.writeFloatBE(-Infinity, 0), 4)
+ t.equal(buf.readFloatBE(0), -Infinity)
+ t.end()
+})
+
+test('write/read Infinity as a double', function (t) {
+ var buf = new B(8)
+ t.equal(buf.writeDoubleBE(Infinity, 0), 8)
+ t.equal(buf.readDoubleBE(0), Infinity)
+ t.end()
+})
+
+test('write/read -Infinity as a double', function (t) {
+ var buf = new B(8)
+ t.equal(buf.writeDoubleBE(-Infinity, 0), 8)
+ t.equal(buf.readDoubleBE(0), -Infinity)
+ t.end()
+})
+
+test('write/read float greater than max', function (t) {
+ var buf = new B(4)
+ t.equal(buf.writeFloatBE(4e38, 0), 4)
+ t.equal(buf.readFloatBE(0), Infinity)
+ t.end()
+})
+
+test('write/read float less than min', function (t) {
+ var buf = new B(4)
+ t.equal(buf.writeFloatBE(-4e40, 0), 4)
+ t.equal(buf.readFloatBE(0), -Infinity)
+ t.end()
+})