4
4
*/
5
5
require ( '../common' ) ;
6
6
const assert = require ( 'assert' ) ;
7
+ const errorOutOfBounds = / ^ T y p e E r r o r : " v a l u e " a r g u m e n t i s o u t o f b o u n d s $ / ;
7
8
8
9
function test8 ( clazz ) {
9
10
var buffer = new clazz ( 2 ) ;
@@ -17,10 +18,10 @@ function test8(clazz) {
17
18
/* Make sure we handle truncation correctly */
18
19
assert . throws ( function ( ) {
19
20
buffer . writeInt8 ( 0xabc , 0 ) ;
20
- } ) ;
21
+ } , errorOutOfBounds ) ;
21
22
assert . throws ( function ( ) {
22
23
buffer . writeInt8 ( 0xabc , 0 ) ;
23
- } ) ;
24
+ } , errorOutOfBounds ) ;
24
25
25
26
/* Make sure we handle min/max correctly */
26
27
buffer . writeInt8 ( 0x7f , 0 ) ;
@@ -30,10 +31,10 @@ function test8(clazz) {
30
31
assert . equal ( 0x80 , buffer [ 1 ] ) ;
31
32
assert . throws ( function ( ) {
32
33
buffer . writeInt8 ( 0x7f + 1 , 0 ) ;
33
- } ) ;
34
+ } , errorOutOfBounds ) ;
34
35
assert . throws ( function ( ) {
35
36
buffer . writeInt8 ( - 0x80 - 1 , 0 ) ;
36
- } ) ;
37
+ } , errorOutOfBounds ) ;
37
38
}
38
39
39
40
@@ -70,10 +71,10 @@ function test16(clazz) {
70
71
assert . equal ( 0x00 , buffer [ 3 ] ) ;
71
72
assert . throws ( function ( ) {
72
73
buffer . writeInt16BE ( 0x7fff + 1 , 0 ) ;
73
- } ) ;
74
+ } , errorOutOfBounds ) ;
74
75
assert . throws ( function ( ) {
75
76
buffer . writeInt16BE ( - 0x8000 - 1 , 0 ) ;
76
- } ) ;
77
+ } , errorOutOfBounds ) ;
77
78
78
79
buffer . writeInt16LE ( 0x7fff , 0 ) ;
79
80
buffer . writeInt16LE ( - 0x8000 , 2 ) ;
@@ -83,10 +84,10 @@ function test16(clazz) {
83
84
assert . equal ( 0x80 , buffer [ 3 ] ) ;
84
85
assert . throws ( function ( ) {
85
86
buffer . writeInt16LE ( 0x7fff + 1 , 0 ) ;
86
- } ) ;
87
+ } , errorOutOfBounds ) ;
87
88
assert . throws ( function ( ) {
88
89
buffer . writeInt16LE ( - 0x8000 - 1 , 0 ) ;
89
- } ) ;
90
+ } , errorOutOfBounds ) ;
90
91
}
91
92
92
93
@@ -139,10 +140,10 @@ function test32(clazz) {
139
140
assert . equal ( 0x00 , buffer [ 7 ] ) ;
140
141
assert . throws ( function ( ) {
141
142
buffer . writeInt32BE ( 0x7fffffff + 1 , 0 ) ;
142
- } ) ;
143
+ } , errorOutOfBounds ) ;
143
144
assert . throws ( function ( ) {
144
145
buffer . writeInt32BE ( - 0x80000000 - 1 , 0 ) ;
145
- } ) ;
146
+ } , errorOutOfBounds ) ;
146
147
147
148
buffer . writeInt32LE ( 0x7fffffff , 0 ) ;
148
149
buffer . writeInt32LE ( - 0x80000000 , 4 ) ;
@@ -156,10 +157,10 @@ function test32(clazz) {
156
157
assert . equal ( 0x80 , buffer [ 7 ] ) ;
157
158
assert . throws ( function ( ) {
158
159
buffer . writeInt32LE ( 0x7fffffff + 1 , 0 ) ;
159
- } ) ;
160
+ } , errorOutOfBounds ) ;
160
161
assert . throws ( function ( ) {
161
162
buffer . writeInt32LE ( - 0x80000000 - 1 , 0 ) ;
162
- } ) ;
163
+ } , errorOutOfBounds ) ;
163
164
}
164
165
165
166
0 commit comments