@@ -263,6 +263,31 @@ describe(module.id, function () {
263263 TNSClearOutput ( ) ;
264264 } ) ;
265265
266+ it ( "should respect ArrayBufferView byteOffset when wrapping in NSData" , function ( ) {
267+ var source = new Uint8Array ( [ 48 , 49 , 50 , 51 , 52 , 53 ] ) ;
268+ var view = new Uint8Array ( source . buffer , 1 , 4 ) ;
269+
270+ var wrappedArrayBufferViewData = TNSObjCTypes . alloc ( ) . init ( ) . methodWithNSData ( view ) ;
271+
272+ expect ( TNSGetOutput ( ) ) . toBe ( '1234' ) ;
273+ expect ( wrappedArrayBufferViewData ) . toBe ( view ) ;
274+ TNSClearOutput ( ) ;
275+ } ) ;
276+
277+ it ( "should respect ArrayBufferView byteOffset when mutating NSMutableData" , function ( ) {
278+ var source = new Uint8Array ( [ 48 , 49 , 50 , 51 , 52 ] ) ;
279+ var view = new Uint8Array ( source . buffer , 2 , 2 ) ;
280+
281+ var wrappedArrayBufferViewData = TNSObjCTypes . alloc ( ) . init ( ) . methodWithNSMutableData ( view ) ;
282+
283+ expect ( wrappedArrayBufferViewData ) . toBe ( view ) ;
284+ expect ( source [ 0 ] ) . toEqual ( 48 ) ;
285+ expect ( source [ 1 ] ) . toEqual ( 49 ) ;
286+ expect ( source [ 2 ] ) . toEqual ( 65 ) ;
287+ expect ( source [ 3 ] ) . toEqual ( 51 ) ;
288+ expect ( source [ 4 ] ) . toEqual ( 52 ) ;
289+ } ) ;
290+
266291 it ( "should be possible to wrap NSData in an ArrayBuffer" , function ( ) {
267292 var data = NSString . stringWithString ( "test" ) . dataUsingEncoding ( NSUTF8StringEncoding ) ;
268293
0 commit comments