summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIrene Li <li.irene1@gmail.com>2017-01-11 20:17:34 -0800
committerItalo A. Casas <me@italoacasas.com>2017-01-13 15:36:03 -0500
commit6782577eef5d6bfe8ea5fad6c1b3b999d7a2ded1 (patch)
treec827ff6b0d40b6d6762b3f1a44e34ea7d0580c05
parent20efbffaf8c5f4af94da31c95ba90e77a2e00e08 (diff)
downloadnode-new-6782577eef5d6bfe8ea5fad6c1b3b999d7a2ded1.tar.gz
test: check error msg test-writeint.js
PR-URL: https://github.com/nodejs/node/pull/10755 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
-rw-r--r--test/parallel/test-writeint.js25
1 files changed, 13 insertions, 12 deletions
diff --git a/test/parallel/test-writeint.js b/test/parallel/test-writeint.js
index d3ca5409f0..70599dc177 100644
--- a/test/parallel/test-writeint.js
+++ b/test/parallel/test-writeint.js
@@ -4,6 +4,7 @@
*/
require('../common');
const assert = require('assert');
+const errorOutOfBounds = /^TypeError: "value" argument is out of bounds$/;
function test8(clazz) {
const buffer = new clazz(2);
@@ -17,10 +18,10 @@ function test8(clazz) {
/* Make sure we handle truncation correctly */
assert.throws(function() {
buffer.writeInt8(0xabc, 0);
- });
+ }, errorOutOfBounds);
assert.throws(function() {
buffer.writeInt8(0xabc, 0);
- });
+ }, errorOutOfBounds);
/* Make sure we handle min/max correctly */
buffer.writeInt8(0x7f, 0);
@@ -30,10 +31,10 @@ function test8(clazz) {
assert.strictEqual(0x80, buffer[1]);
assert.throws(function() {
buffer.writeInt8(0x7f + 1, 0);
- });
+ }, errorOutOfBounds);
assert.throws(function() {
buffer.writeInt8(-0x80 - 1, 0);
- });
+ }, errorOutOfBounds);
}
@@ -70,10 +71,10 @@ function test16(clazz) {
assert.strictEqual(0x00, buffer[3]);
assert.throws(function() {
buffer.writeInt16BE(0x7fff + 1, 0);
- });
+ }, errorOutOfBounds);
assert.throws(function() {
buffer.writeInt16BE(-0x8000 - 1, 0);
- });
+ }, errorOutOfBounds);
buffer.writeInt16LE(0x7fff, 0);
buffer.writeInt16LE(-0x8000, 2);
@@ -83,10 +84,10 @@ function test16(clazz) {
assert.strictEqual(0x80, buffer[3]);
assert.throws(function() {
buffer.writeInt16LE(0x7fff + 1, 0);
- });
+ }, errorOutOfBounds);
assert.throws(function() {
buffer.writeInt16LE(-0x8000 - 1, 0);
- });
+ }, errorOutOfBounds);
}
@@ -139,10 +140,10 @@ function test32(clazz) {
assert.strictEqual(0x00, buffer[7]);
assert.throws(function() {
buffer.writeInt32BE(0x7fffffff + 1, 0);
- });
+ }, errorOutOfBounds);
assert.throws(function() {
buffer.writeInt32BE(-0x80000000 - 1, 0);
- });
+ }, errorOutOfBounds);
buffer.writeInt32LE(0x7fffffff, 0);
buffer.writeInt32LE(-0x80000000, 4);
@@ -156,10 +157,10 @@ function test32(clazz) {
assert.strictEqual(0x80, buffer[7]);
assert.throws(function() {
buffer.writeInt32LE(0x7fffffff + 1, 0);
- });
+ }, errorOutOfBounds);
assert.throws(function() {
buffer.writeInt32LE(-0x80000000 - 1, 0);
- });
+ }, errorOutOfBounds);
}