@@ -531,6 +531,45 @@ describe("buffer", () => {
531531 expected = create < Buffer > ( [ 5 , 6 , 7 ] ) ;
532532 expect < Buffer > ( actual ) . toStrictEqual ( expected ) ;
533533 } ) ;
534+
535+ test ( "#swap16" , ( ) => {
536+ let actual = create < Buffer > ( [ 0x1 , 0x2 , 0x3 , 0x4 , 0x5 , 0x6 , 0x7 , 0x8 ] ) ;
537+ let expected = create < Buffer > ( [ 0x2 , 0x1 , 0x4 , 0x3 , 0x6 , 0x5 , 0x8 , 0x7 ] ) ;
538+ let swapped = actual . swap16 ( ) ;
539+ expect < Buffer > ( actual ) . toStrictEqual ( expected ) ;
540+ expect < Buffer > ( swapped ) . toBe ( actual ) ;
541+ // TODO:
542+ // expectFn(() => {
543+ // let newBuff = create<Buffer>([0x1, 0x2, 0x3]);
544+ // newBuff.swap16();
545+ // }).toThrow();
546+ } ) ;
547+
548+ test ( "#swap32" , ( ) => {
549+ let actual = create < Buffer > ( [ 0x1 , 0x2 , 0x3 , 0x4 , 0x5 , 0x6 , 0x7 , 0x8 ] ) ;
550+ let expected = create < Buffer > ( [ 0x4 , 0x3 , 0x2 , 0x1 , 0x8 , 0x7 , 0x6 , 0x5 ] ) ;
551+ let swapped = actual . swap32 ( ) ;
552+ expect < Buffer > ( actual ) . toStrictEqual ( expected ) ;
553+ expect < Buffer > ( swapped ) . toBe ( actual ) ;
554+ // TODO:
555+ // expectFn(() => {
556+ // let newBuff = create<Buffer>([0x1, 0x2, 0x3]);
557+ // newBuff.swap64();
558+ // }).toThrow();
559+ } ) ;
560+
561+ test ( "#swap64" , ( ) => {
562+ let actual = create < Buffer > ( [ 0x0 , 0x1 , 0x2 , 0x3 , 0x4 , 0x5 , 0x6 , 0x7 , 0x8 , 0x9 , 0xa , 0xb , 0xc , 0xd , 0xe , 0xf ] ) ;
563+ let expected = create < Buffer > ( [ 0x7 , 0x6 , 0x5 , 0x4 , 0x3 , 0x2 , 0x1 , 0x0 , 0xf , 0xe , 0xd , 0xc , 0xb , 0xa , 0x9 , 0x8 ] ) ;
564+ let swapped = actual . swap64 ( ) ;
565+ expect < Buffer > ( actual ) . toStrictEqual ( expected ) ;
566+ expect < Buffer > ( swapped ) . toBe ( actual ) ;
567+ // TODO:
568+ // expectFn(() => {
569+ // let newBuff = create<Buffer>([0x1, 0x2, 0x3]);
570+ // newBuff.swap64();
571+ // }).toThrow();
572+ } ) ;
534573
535574 test ( "#Hex.encode" , ( ) => {
536575 let actual = "000102030405060708090a0b0c0d0e0f102030405060708090a0b0c0d0e0f0" ;
0 commit comments