44 */
55require ( '../common' ) ;
66const 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 $ / ;
78
89function test8 ( clazz ) {
910 var buffer = new clazz ( 2 ) ;
@@ -17,10 +18,10 @@ function test8(clazz) {
1718 /* Make sure we handle truncation correctly */
1819 assert . throws ( function ( ) {
1920 buffer . writeInt8 ( 0xabc , 0 ) ;
20- } ) ;
21+ } , errorOutOfBounds ) ;
2122 assert . throws ( function ( ) {
2223 buffer . writeInt8 ( 0xabc , 0 ) ;
23- } ) ;
24+ } , errorOutOfBounds ) ;
2425
2526 /* Make sure we handle min/max correctly */
2627 buffer . writeInt8 ( 0x7f , 0 ) ;
@@ -30,10 +31,10 @@ function test8(clazz) {
3031 assert . equal ( 0x80 , buffer [ 1 ] ) ;
3132 assert . throws ( function ( ) {
3233 buffer . writeInt8 ( 0x7f + 1 , 0 ) ;
33- } ) ;
34+ } , errorOutOfBounds ) ;
3435 assert . throws ( function ( ) {
3536 buffer . writeInt8 ( - 0x80 - 1 , 0 ) ;
36- } ) ;
37+ } , errorOutOfBounds ) ;
3738}
3839
3940
@@ -70,10 +71,10 @@ function test16(clazz) {
7071 assert . equal ( 0x00 , buffer [ 3 ] ) ;
7172 assert . throws ( function ( ) {
7273 buffer . writeInt16BE ( 0x7fff + 1 , 0 ) ;
73- } ) ;
74+ } , errorOutOfBounds ) ;
7475 assert . throws ( function ( ) {
7576 buffer . writeInt16BE ( - 0x8000 - 1 , 0 ) ;
76- } ) ;
77+ } , errorOutOfBounds ) ;
7778
7879 buffer . writeInt16LE ( 0x7fff , 0 ) ;
7980 buffer . writeInt16LE ( - 0x8000 , 2 ) ;
@@ -83,10 +84,10 @@ function test16(clazz) {
8384 assert . equal ( 0x80 , buffer [ 3 ] ) ;
8485 assert . throws ( function ( ) {
8586 buffer . writeInt16LE ( 0x7fff + 1 , 0 ) ;
86- } ) ;
87+ } , errorOutOfBounds ) ;
8788 assert . throws ( function ( ) {
8889 buffer . writeInt16LE ( - 0x8000 - 1 , 0 ) ;
89- } ) ;
90+ } , errorOutOfBounds ) ;
9091}
9192
9293
@@ -139,10 +140,10 @@ function test32(clazz) {
139140 assert . equal ( 0x00 , buffer [ 7 ] ) ;
140141 assert . throws ( function ( ) {
141142 buffer . writeInt32BE ( 0x7fffffff + 1 , 0 ) ;
142- } ) ;
143+ } , errorOutOfBounds ) ;
143144 assert . throws ( function ( ) {
144145 buffer . writeInt32BE ( - 0x80000000 - 1 , 0 ) ;
145- } ) ;
146+ } , errorOutOfBounds ) ;
146147
147148 buffer . writeInt32LE ( 0x7fffffff , 0 ) ;
148149 buffer . writeInt32LE ( - 0x80000000 , 4 ) ;
@@ -156,10 +157,10 @@ function test32(clazz) {
156157 assert . equal ( 0x80 , buffer [ 7 ] ) ;
157158 assert . throws ( function ( ) {
158159 buffer . writeInt32LE ( 0x7fffffff + 1 , 0 ) ;
159- } ) ;
160+ } , errorOutOfBounds ) ;
160161 assert . throws ( function ( ) {
161162 buffer . writeInt32LE ( - 0x80000000 - 1 , 0 ) ;
162- } ) ;
163+ } , errorOutOfBounds ) ;
163164}
164165
165166
0 commit comments