@@ -358,6 +358,150 @@ describe("buffer", () => {
358358 // }).toThrow();
359359 } ) ;
360360
361+ test ( "#readBigInt64LE" , ( ) => {
362+ let buff = create < Buffer > ( [ 0x00 , 0x00 , 0x00 , 0x00 , 0xff , 0xff , 0xff , 0xff , 0xff , 0xff , 0xff , 0xff , 0x00 , 0x00 , 0x00 , 0x00 ] ) ;
363+ expect < i64 > ( buff . readBigInt64LE ( ) ) . toBe ( - 4294967296 ) ;
364+ expect < i64 > ( buff . readBigInt64LE ( 8 ) ) . toBe ( 4294967295 ) ;
365+ // TODO:
366+ // expectFn(() => {
367+ // let newBuff = new Buffer(1);
368+ // newBuff.readBigInt64LE(0);
369+ // }).toThrow();
370+ } ) ;
371+
372+ test ( "#readBigInt64BE" , ( ) => {
373+ let buff = create < Buffer > ( [ 0x00 , 0x00 , 0x00 , 0x00 , 0xff , 0xff , 0xff , 0xff , 0xff , 0xff , 0xff , 0xff , 0x00 , 0x00 , 0x00 , 0x00 ] ) ;
374+ expect < i64 > ( buff . readBigInt64BE ( ) ) . toBe ( 4294967295 ) ;
375+ expect < i64 > ( buff . readBigInt64BE ( 8 ) ) . toBe ( - 4294967296 ) ;
376+ // TODO:
377+ // expectFn(() => {
378+ // let newBuff = new Buffer(1);
379+ // newBuff.readBigInt64BE(0);
380+ // }).toThrow();
381+ } ) ;
382+
383+ test ( "#readBigUInt64LE" , ( ) => {
384+ let buff = create < Buffer > ( [ 0x00 , 0x00 , 0x00 , 0x00 , 0xff , 0xff , 0xff , 0xff , 0xff , 0xff , 0xff , 0xff , 0x00 , 0x00 , 0x00 , 0x00 ] ) ;
385+ expect < u64 > ( buff . readBigUInt64LE ( ) ) . toBe ( 18446744069414584320 ) ;
386+ expect < u64 > ( buff . readBigUInt64LE ( 8 ) ) . toBe ( 4294967295 ) ;
387+ // TODO:
388+ // expectFn(() => {
389+ // let newBuff = new Buffer(1);
390+ // newBuff.readBigUInt64LE(0);
391+ // }).toThrow();
392+ } ) ;
393+
394+ test ( "#readBigUInt64BE" , ( ) => {
395+ let buff = create < Buffer > ( [ 0x00 , 0x00 , 0x00 , 0x00 , 0xff , 0xff , 0xff , 0xff , 0xff , 0xff , 0xff , 0xff , 0x00 , 0x00 , 0x00 , 0x00 ] ) ;
396+ expect < u64 > ( buff . readBigUInt64BE ( ) ) . toBe ( 4294967295 ) ;
397+ expect < u64 > ( buff . readBigUInt64BE ( 8 ) ) . toBe ( 18446744069414584320 ) ;
398+ // TODO:
399+ // expectFn(() => {
400+ // let newBuff = new Buffer(1);
401+ // newBuff.readBigUInt64BE(0);
402+ // }).toThrow();
403+ } ) ;
404+
405+ test ( "#writeBigInt64LE" , ( ) => {
406+ let buff = new Buffer ( 16 ) ;
407+ expect < i64 > ( buff . writeBigInt64LE ( - 559038737 ) ) . toBe ( 8 ) ;
408+ expect < i64 > ( buff . writeBigInt64LE ( 283033613 , 8 ) ) . toBe ( 16 ) ;
409+ let result = create < Buffer > ( [ 0xEF , 0xBE , 0xAD , 0xDE , 0xFF , 0xFF , 0xFF , 0xFF , 0x0d , 0xc0 , 0xde , 0x10 , 0x00 , 0x00 , 0x00 , 0x00 ] ) ;
410+ expect < Buffer > ( buff ) . toStrictEqual ( result ) ;
411+ // TODO:
412+ // expectFn(() => {
413+ // let newBuff = new Buffer(1);
414+ // newBuff.writeBigInt64LE(0);
415+ // }).toThrow();
416+ } ) ;
417+
418+ test ( "#writeBigInt64BE" , ( ) => {
419+ let buff = new Buffer ( 16 ) ;
420+ expect < i64 > ( buff . writeBigInt64BE ( - 559038737 ) ) . toBe ( 8 ) ;
421+ expect < i64 > ( buff . writeBigInt64BE ( 283033613 , 8 ) ) . toBe ( 16 ) ;
422+ let result = create < Buffer > ( [ 0xFF , 0xFF , 0xFF , 0xFF , 0xDE , 0xAD , 0xBE , 0xEF , 0x00 , 0x00 , 0x00 , 0x00 , 0x10 , 0xde , 0xc0 , 0x0d ] ) ;
423+ expect < Buffer > ( buff ) . toStrictEqual ( result ) ;
424+ // TODO:
425+ // expectFn(() => {
426+ // let newBuff = new Buffer(1);
427+ // newBuff.writeBigInt64BE(0);
428+ // }).toThrow();
429+ } ) ;
430+
431+ test ( "#writeBigUInt64LE" , ( ) => {
432+ let buff = new Buffer ( 16 ) ;
433+ expect < i64 > ( buff . writeBigUInt64LE ( 3735928559 ) ) . toBe ( 8 ) ;
434+ expect < i64 > ( buff . writeBigUInt64LE ( 283033613 , 8 ) ) . toBe ( 16 ) ;
435+ let result = create < Buffer > ( [ 0xEF , 0xBE , 0xAD , 0xDE , 0x00 , 0x00 , 0x00 , 0x00 , 0x0d , 0xc0 , 0xde , 0x10 , 0x00 , 0x00 , 0x00 , 0x00 ] ) ;
436+ expect < Buffer > ( buff ) . toStrictEqual ( result ) ;
437+ // TODO:
438+ // expectFn(() => {
439+ // let newBuff = new Buffer(1);
440+ // newBuff.writeBigUInt64LE(0);
441+ // }).toThrow();
442+ } ) ;
443+
444+ test ( "#writeBigUInt64BE" , ( ) => {
445+ let buff = new Buffer ( 16 ) ;
446+ expect < i64 > ( buff . writeBigUInt64BE ( 3735928559 ) ) . toBe ( 8 ) ;
447+ expect < i64 > ( buff . writeBigUInt64BE ( 283033613 , 8 ) ) . toBe ( 16 ) ;
448+ let result = create < Buffer > ( [ 0x00 , 0x00 , 0x00 , 0x00 , 0xDE , 0xAD , 0xBE , 0xEF , 0x00 , 0x00 , 0x00 , 0x00 , 0x10 , 0xde , 0xc0 , 0x0d ] ) ;
449+ expect < Buffer > ( buff ) . toStrictEqual ( result ) ;
450+ // TODO:
451+ // expectFn(() => {
452+ // let newBuff = new Buffer(1);
453+ // newBuff.writeBigUInt64BE(0);
454+ // }).toThrow();
455+ } ) ;
456+
457+ test ( "#readDoubleLE" , ( ) => {
458+ let buff = create < Buffer > ( [ 0x77 , 0xbe , 0x9f , 0x1a , 0x2f , 0xdd , 0x5e , 0x40 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 , 0x08 ] ) ;
459+ expect < f64 > ( buff . readDoubleLE ( ) ) . toBe ( 123.456 ) ;
460+ expect < f64 > ( buff . readDoubleLE ( 8 ) ) . toBe ( 5.447603722011605e-270 ) ;
461+ // TODO:
462+ // expectFn(() => {
463+ // let newBuff = new Buffer(1);
464+ // newBuff.readDoubleLE(0);
465+ // }).toThrow();
466+ } ) ;
467+
468+ test ( "#readDoubleBE" , ( ) => {
469+ let buff = create < Buffer > ( [ 0x40 , 0x5e , 0xdd , 0x2f , 0x1a , 0x9f , 0xbe , 0x77 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 , 0x08 ] ) ;
470+ expect < f64 > ( buff . readDoubleBE ( ) ) . toBe ( 123.456 ) ;
471+ expect < f64 > ( buff . readDoubleBE ( 8 ) ) . toBe ( 8.20788039913184e-304 ) ;
472+ // TODO:
473+ // expectFn(() => {
474+ // let newBuff = new Buffer(1);
475+ // newBuff.readDoubleBE(0);
476+ // }).toThrow();
477+ } ) ;
478+
479+ test ( "#writeDoubleLE" , ( ) => {
480+ let buff = new Buffer ( 16 ) ;
481+ expect < i32 > ( buff . writeDoubleLE ( 123.456 ) ) . toBe ( 8 ) ;
482+ expect < i32 > ( buff . writeDoubleLE ( 5.447603722011605e-270 , 8 ) ) . toBe ( 16 ) ;
483+ let result = create < Buffer > ( [ 0x77 , 0xbe , 0x9f , 0x1a , 0x2f , 0xdd , 0x5e , 0x40 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 , 0x08 ] ) ;
484+ expect < Buffer > ( buff ) . toStrictEqual ( result ) ;
485+ // TODO:
486+ // expectFn(() => {
487+ // let newBuff = new Buffer(1);
488+ // newBuff.writeDoubleLE(0);
489+ // }).toThrow();
490+ } ) ;
491+
492+ test ( "#writeDoubleBE" , ( ) => {
493+ let buff = new Buffer ( 16 ) ;
494+ expect < i32 > ( buff . writeDoubleBE ( 123.456 ) ) . toBe ( 8 ) ;
495+ expect < i32 > ( buff . writeDoubleBE ( 8.20788039913184e-304 , 8 ) ) . toBe ( 16 ) ;
496+ let result = create < Buffer > ( [ 0x40 , 0x5e , 0xdd , 0x2f , 0x1a , 0x9f , 0xbe , 0x77 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 , 0x08 ] ) ;
497+ expect < Buffer > ( buff ) . toStrictEqual ( result ) ;
498+ // TODO:
499+ // expectFn(() => {
500+ // let newBuff = new Buffer(1);
501+ // newBuff.writeDoubleBE(0);
502+ // }).toThrow();
503+ } ) ;
504+
361505 test ( "#subarray" , ( ) => {
362506 let example = create < Buffer > ( [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 ] ) ;
363507
0 commit comments