@ -79,62 +79,94 @@ assert.equal(b.indexOf(Buffer.from('f'), 6), -1);
assert . equal ( Buffer . from ( 'ff' ) . indexOf ( Buffer . from ( 'f' ) , 1 , 'ucs2' ) , - 1 ) ;
assert . equal ( Buffer . from ( 'ff' ) . indexOf ( Buffer . from ( 'f' ) , 1 , 'ucs2' ) , - 1 ) ;
// test hex encoding
// test hex encoding
assert . equal (
assert . strictEqual (
Buffer . from ( b . toString ( 'hex' ) , 'hex' )
Buffer . from ( b . toString ( 'hex' ) , 'hex' )
. indexOf ( '64' , 0 , 'hex' ) , 3 ) ;
. indexOf ( '64' , 0 , 'hex' ) ,
assert . equal (
3
Buffer . from ( b . toString ( 'hex' ) , 'hex' )
) ;
. indexOf ( Buffer . from ( '64' , 'hex' ) , 0 , 'hex' ) , 3 ) ;
assert . strictEqual (
Buffer . from ( b . toString ( 'hex' ) , 'hex' )
. indexOf ( Buffer . from ( '64' , 'hex' ) , 0 , 'hex' ) ,
3
) ;
// test base64 encoding
// test base64 encoding
assert . equal (
assert . strictEqual (
Buffer . from ( b . toString ( 'base64' ) , 'base64' )
Buffer . from ( b . toString ( 'base64' ) , 'base64' )
. indexOf ( 'ZA==' , 0 , 'base64' ) , 3 ) ;
. indexOf ( 'ZA==' , 0 , 'base64' ) ,
assert . equal (
3
Buffer . from ( b . toString ( 'base64' ) , 'base64' )
) ;
. indexOf ( Buffer . from ( 'ZA==' , 'base64' ) , 0 , 'base64' ) , 3 ) ;
assert . strictEqual (
Buffer . from ( b . toString ( 'base64' ) , 'base64' )
. indexOf ( Buffer . from ( 'ZA==' , 'base64' ) , 0 , 'base64' ) ,
3
) ;
// test ascii encoding
// test ascii encoding
assert . equal (
assert . strictEqual (
Buffer . from ( b . toString ( 'ascii' ) , 'ascii' )
Buffer . from ( b . toString ( 'ascii' ) , 'ascii' )
. indexOf ( 'd' , 0 , 'ascii' ) , 3 ) ;
. indexOf ( 'd' , 0 , 'ascii' ) ,
assert . equal (
3
Buffer . from ( b . toString ( 'ascii' ) , 'ascii' )
) ;
. indexOf ( Buffer . from ( 'd' , 'ascii' ) , 0 , 'ascii' ) , 3 ) ;
assert . strictEqual (
Buffer . from ( b . toString ( 'ascii' ) , 'ascii' )
. indexOf ( Buffer . from ( 'd' , 'ascii' ) , 0 , 'ascii' ) ,
3
) ;
// test latin1 encoding
// test latin1 encoding
assert . equal (
assert . strictEqual (
Buffer . from ( b . toString ( 'latin1' ) , 'latin1' )
Buffer . from ( b . toString ( 'latin1' ) , 'latin1' )
. indexOf ( 'd' , 0 , 'latin1' ) , 3 ) ;
. indexOf ( 'd' , 0 , 'latin1' ) ,
assert . equal (
3
Buffer . from ( b . toString ( 'latin1' ) , 'latin1' )
) ;
. indexOf ( Buffer . from ( 'd' , 'latin1' ) , 0 , 'latin1' ) , 3 ) ;
assert . strictEqual (
assert . equal (
Buffer . from ( b . toString ( 'latin1' ) , 'latin1' )
Buffer . from ( 'aa\u00e8aa' , 'latin1' )
. indexOf ( Buffer . from ( 'd' , 'latin1' ) , 0 , 'latin1' ) ,
. indexOf ( '\u00e8' , 'latin1' ) , 2 ) ;
3
assert . equal (
) ;
Buffer . from ( '\u00e8' , 'latin1' )
assert . strictEqual (
. indexOf ( '\u00e8' , 'latin1' ) , 0 ) ;
Buffer . from ( 'aa\u00e8aa' , 'latin1' )
assert . equal (
. indexOf ( '\u00e8' , 'latin1' ) ,
Buffer . from ( '\u00e8' , 'latin1' )
2
. indexOf ( Buffer . from ( '\u00e8' , 'latin1' ) , 'latin1' ) , 0 ) ;
) ;
assert . strictEqual (
Buffer . from ( '\u00e8' , 'latin1' )
. indexOf ( '\u00e8' , 'latin1' ) ,
0
) ;
assert . strictEqual (
Buffer . from ( '\u00e8' , 'latin1' )
. indexOf ( Buffer . from ( '\u00e8' , 'latin1' ) , 'latin1' ) ,
0
) ;
// test binary encoding
// test binary encoding
assert . equal (
assert . strictEqual (
Buffer . from ( b . toString ( 'binary' ) , 'binary' )
Buffer . from ( b . toString ( 'binary' ) , 'binary' )
. indexOf ( 'd' , 0 , 'binary' ) , 3 ) ;
. indexOf ( 'd' , 0 , 'binary' ) ,
assert . equal (
3
Buffer . from ( b . toString ( 'binary' ) , 'binary' )
) ;
. indexOf ( Buffer . from ( 'd' , 'binary' ) , 0 , 'binary' ) , 3 ) ;
assert . strictEqual (
assert . equal (
Buffer . from ( b . toString ( 'binary' ) , 'binary' )
Buffer . from ( 'aa\u00e8aa' , 'binary' )
. indexOf ( Buffer . from ( 'd' , 'binary' ) , 0 , 'binary' ) ,
. indexOf ( '\u00e8' , 'binary' ) , 2 ) ;
3
assert . equal (
) ;
Buffer . from ( '\u00e8' , 'binary' )
assert . strictEqual (
. indexOf ( '\u00e8' , 'binary' ) , 0 ) ;
Buffer . from ( 'aa\u00e8aa' , 'binary' )
assert . equal (
. indexOf ( '\u00e8' , 'binary' ) ,
Buffer . from ( '\u00e8' , 'binary' )
2
. indexOf ( Buffer . from ( '\u00e8' , 'binary' ) , 'binary' ) , 0 ) ;
) ;
assert . strictEqual (
Buffer . from ( '\u00e8' , 'binary' )
. indexOf ( '\u00e8' , 'binary' ) ,
0
) ;
assert . strictEqual (
Buffer . from ( '\u00e8' , 'binary' )
. indexOf ( Buffer . from ( '\u00e8' , 'binary' ) , 'binary' ) ,
0
) ;
// test optional offset with passed encoding
// test optional offset with passed encoding