@@ -278,18 +278,16 @@ describe("UnicodeStringArray", () => {
278
278
} ) . toStrictEqual ( {
279
279
length : 2 ,
280
280
BYTES_PER_ELEMENT : chars * 4 ,
281
- byteOffset : 1 * chars * 4 ,
282
- byteLength : 2 * chars * 4 ,
281
+ byteOffset : chars * 4 ,
282
+ byteLength : chars * 4 * 2 ,
283
283
data : [ "Hej Världen!" , "Xin chào thế giới" ] ,
284
284
} ) ;
285
285
} ) ;
286
286
287
287
test ( "new (values: Iterable<string>) -> UnicodeStringArray" , ( ) => {
288
- let arr = new UnicodeStringArray ( 20 , [
289
- "¡Hola mundo!" ,
290
- "Hej Världen!" ,
291
- "Xin chào thế giới" ,
292
- ] ) ;
288
+ let chars = 20 ;
289
+ let data = [ "¡Hola mundo!" , "Hej Världen!" , "Xin chào thế giới" ] ;
290
+ let arr = new UnicodeStringArray ( 20 , data ) ;
293
291
expect ( {
294
292
length : arr . length ,
295
293
BYTES_PER_ELEMENT : arr . BYTES_PER_ELEMENT ,
@@ -300,13 +298,26 @@ describe("UnicodeStringArray", () => {
300
298
arr . byteOffset ,
301
299
arr . byteLength / Int32Array . BYTES_PER_ELEMENT ,
302
300
) ,
301
+ encoded_sub_view : new Int32Array (
302
+ arr . buffer ,
303
+ arr . byteOffset + arr . BYTES_PER_ELEMENT ,
304
+ chars ,
305
+ ) ,
303
306
} ) . toStrictEqual ( {
304
- length : 3 ,
305
- BYTES_PER_ELEMENT : 20 * 4 ,
307
+ length : data . length ,
308
+ BYTES_PER_ELEMENT : chars * Int32Array . BYTES_PER_ELEMENT ,
306
309
byteOffset : 0 ,
307
- byteLength : 3 * 20 * 4 ,
310
+ byteLength : data . length * chars * Int32Array . BYTES_PER_ELEMENT ,
311
+ // deno-fmt-ignore
312
+ encoded : new Int32Array ( [
313
+ 161 , 72 , 111 , 108 , 97 , 32 , 109 , 117 , 110 , 100 , 111 , 33 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
314
+ 72 , 101 , 106 , 32 , 86 , 228 , 114 , 108 , 100 , 101 , 110 , 33 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
315
+ 88 , 105 , 110 , 32 , 99 , 104 , 224 , 111 , 32 , 116 , 104 , 7871 , 32 , 103 , 105 , 7899 , 105 , 0 , 0 , 0 ,
316
+ ] ) ,
308
317
// deno-fmt-ignore
309
- encoded : new Int32Array ( [ 161 , 72 , 111 , 108 , 97 , 32 , 109 , 117 , 110 , 100 , 111 , 33 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 72 , 101 , 106 , 32 , 86 , 228 , 114 , 108 , 100 , 101 , 110 , 33 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 88 , 105 , 110 , 32 , 99 , 104 , 224 , 111 , 32 , 116 , 104 , 7871 , 32 , 103 , 105 , 7899 , 105 , 0 , 0 , 0 ] ) ,
318
+ encoded_sub_view : new Int32Array ( [
319
+ 72 , 101 , 106 , 32 , 86 , 228 , 114 , 108 , 100 , 101 , 110 , 33 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
320
+ ] ) ,
310
321
} ) ;
311
322
} ) ;
312
323
0 commit comments