-
Notifications
You must be signed in to change notification settings - Fork 577
/
Copy pathbyte_array_test.cairo
568 lines (473 loc) · 20 KB
/
byte_array_test.cairo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
use core::test::test_utils::{assert_eq, assert_ne};
#[test]
fn test_append_byte() {
let mut ba = Default::default();
let mut c = 1_u8;
loop {
if c == 34 {
break;
}
ba.append_byte(c);
c += 1;
};
let expected_data = array![0x0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f];
compare_byte_array(@ba, expected_data.span(), 2, 0x2021);
}
#[test]
fn test_append_word() {
let mut ba = Default::default();
ba.append_word(0x0102030405060708091a0b0c0d0e0f101112131415161718191a1b1c1d1e, 30);
compare_byte_array(
@ba, array![].span(), 30, 0x0102030405060708091a0b0c0d0e0f101112131415161718191a1b1c1d1e
);
ba.append_word(0x1f2021, 3);
let expected_data = array![0x0102030405060708091a0b0c0d0e0f101112131415161718191a1b1c1d1e1f];
compare_byte_array(@ba, expected_data.span(), 2, 0x2021);
ba.append_word(0x2223, 2);
compare_byte_array(@ba, expected_data.span(), 4, 0x20212223);
// Length is 0, so nothing is actually appended.
ba.append_word(0xffee, 0);
compare_byte_array(@ba, expected_data.span(), 4, 0x20212223);
ba.append_word(0x2425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e, 27);
let expected_data = array![
0x0102030405060708091a0b0c0d0e0f101112131415161718191a1b1c1d1e1f,
0x202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e
];
compare_byte_array(@ba, expected_data.span(), 0, 0);
ba.append_word(0x3f, 1);
compare_byte_array(@ba, expected_data.span(), 1, 0x3f);
}
#[test]
fn test_append() {
let mut ba1 = test_byte_array_32();
let ba2 = test_byte_array_32();
ba1.append(@ba2);
let expected_data = array![
0x0102030405060708091a0b0c0d0e0f101112131415161718191a1b1c1d1e1f,
0x200102030405060708091a0b0c0d0e0f101112131415161718191a1b1c1d1e
];
compare_byte_array(@ba1, expected_data.span(), 2, 0x1f20);
}
// Same as test_append, but with `+=` instead of `append`.
#[test]
fn test_add_eq() {
let mut ba1 = test_byte_array_32();
let ba2 = test_byte_array_32();
ba1 += ba2;
let expected_data = array![
0x0102030405060708091a0b0c0d0e0f101112131415161718191a1b1c1d1e1f,
0x200102030405060708091a0b0c0d0e0f101112131415161718191a1b1c1d1e
];
compare_byte_array(@ba1, expected_data.span(), 2, 0x1f20);
}
#[test]
fn test_concat() {
let ba1 = test_byte_array_32();
let ba2 = test_byte_array_32();
let ba3 = ByteArrayTrait::concat(@ba1, @ba2);
let expected_data = array![
0x0102030405060708091a0b0c0d0e0f101112131415161718191a1b1c1d1e1f,
0x200102030405060708091a0b0c0d0e0f101112131415161718191a1b1c1d1e
];
compare_byte_array(@ba3, expected_data.span(), 2, 0x1f20);
}
// Same as test_concat, but with `+` instead of `concat`.
#[test]
fn test_add() {
let ba1 = test_byte_array_32();
let ba2 = test_byte_array_32();
let ba3 = ba1 + ba2;
let expected_data = array![
0x0102030405060708091a0b0c0d0e0f101112131415161718191a1b1c1d1e1f,
0x200102030405060708091a0b0c0d0e0f101112131415161718191a1b1c1d1e
];
compare_byte_array(@ba3, expected_data.span(), 2, 0x1f20);
}
// Test concat/append, first byte array empty.
#[test]
fn test_concat_first_empty() {
let ba1 = Default::default();
let ba2 = test_byte_array_32();
let ba3 = ByteArrayTrait::concat(@ba1, @ba2);
let expected_data = array![0x0102030405060708091a0b0c0d0e0f101112131415161718191a1b1c1d1e1f];
compare_byte_array(@ba3, expected_data.span(), 1, 0x20);
}
// Test concat/append, second byte array empty.
#[test]
fn test_concat_second_empty() {
let ba1 = test_byte_array_32();
let ba2 = Default::default();
let ba3 = ByteArrayTrait::concat(@ba1, @ba2);
let expected_data = array![0x0102030405060708091a0b0c0d0e0f101112131415161718191a1b1c1d1e1f];
compare_byte_array(@ba3, expected_data.span(), 1, 0x20);
}
// Test concat/append, first byte array pending word is empty.
#[test]
fn test_concat_first_pending_0() {
let ba1 = test_byte_array_31();
let ba2 = test_byte_array_32();
let ba3 = ByteArrayTrait::concat(@ba1, @ba2);
let expected_data = array![
0x0102030405060708091a0b0c0d0e0f101112131415161718191a1b1c1d1e1f,
0x0102030405060708091a0b0c0d0e0f101112131415161718191a1b1c1d1e1f
];
compare_byte_array(@ba3, expected_data.span(), 1, 0x20);
}
// Test concat/append, second byte array pending word is empty.
#[test]
fn test_concat_second_pending_0() {
let ba1 = test_byte_array_32();
let ba2 = test_byte_array_31();
let ba3 = ByteArrayTrait::concat(@ba1, @ba2);
let expected_data = array![
0x0102030405060708091a0b0c0d0e0f101112131415161718191a1b1c1d1e1f,
0x200102030405060708091a0b0c0d0e0f101112131415161718191a1b1c1d1e
];
compare_byte_array(@ba3, expected_data.span(), 1, 0x1f);
}
// Test concat/append, split index of the words of the second byte array is 16.
#[test]
fn test_concat_split_index_16() {
let ba1 = test_byte_array_16();
let ba2 = test_byte_array_32();
let ba3 = ByteArrayTrait::concat(@ba1, @ba2);
let expected_data = array![0x0102030405060708091a0b0c0d0e0f100102030405060708091a0b0c0d0e0f];
compare_byte_array(@ba3, expected_data.span(), 17, 0x101112131415161718191a1b1c1d1e1f20);
}
// Test concat/append, split index of the words of the second byte array is < 16, specifically 1.
#[test]
fn test_concat_split_index_lt_16() {
let ba1 = test_byte_array_1();
let ba2 = test_byte_array_32();
let ba3 = ByteArrayTrait::concat(@ba1, @ba2);
let expected_data = array![0x010102030405060708091a0b0c0d0e0f101112131415161718191a1b1c1d1e];
compare_byte_array(@ba3, expected_data.span(), 2, 0x1f20);
}
// Test concat/append, split index of the words of the second byte array is > 16, specifically 30.
#[test]
fn test_concat_split_index_gt_16() {
let ba1 = test_byte_array_30();
let ba2 = test_byte_array_33();
let ba3 = ByteArrayTrait::concat(@ba1, @ba2);
let expected_data = array![
0x0102030405060708091a0b0c0d0e0f101112131415161718191a1b1c1d1e01,
0x02030405060708091a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20
];
compare_byte_array(@ba3, expected_data.span(), 1, 0x21);
}
// Sum of the lengths of the pending words of both byte arrays is 31 (a full word).
#[test]
fn test_concat_pending_sum_up_to_full() {
let ba1 = test_byte_array_32();
let ba2 = test_byte_array_30();
let ba3 = ByteArrayTrait::concat(@ba1, @ba2);
let expected_data = array![
0x0102030405060708091a0b0c0d0e0f101112131415161718191a1b1c1d1e1f,
0x200102030405060708091a0b0c0d0e0f101112131415161718191a1b1c1d1e
];
compare_byte_array(@ba3, expected_data.span(), 0, 0);
}
// Sum of the lengths of the pending words of both byte arrays is 31+16.
// That is, the pending words aggregate to a full word, and the last split index is 16.
#[test]
fn test_concat_pending_sum_up_to_more_than_word_16() {
let ba1 = test_byte_array_17();
let ba2 = test_byte_array_30();
let ba3 = ByteArrayTrait::concat(@ba1, @ba2);
let expected_data = array![0x0102030405060708091a0b0c0d0e0f10110102030405060708091a0b0c0d0e];
compare_byte_array(@ba3, expected_data.span(), 16, 0x0f101112131415161718191a1b1c1d1e);
}
// Sum of the lengths of the pending words of both byte arrays is in [32, 31+15].
// That is, the pending words aggregate to a full word, and the last split index is <16.
#[test]
fn test_concat_pending_sum_up_to_more_than_word_lt16() {
let ba1 = test_byte_array_2();
let ba2 = test_byte_array_30();
let ba3 = ByteArrayTrait::concat(@ba1, @ba2);
let expected_data = array![0x01020102030405060708091a0b0c0d0e0f101112131415161718191a1b1c1d];
compare_byte_array(@ba3, expected_data.span(), 1, 0x1e);
}
// Sum of the lengths of the pending words of both byte arrays is >31+15
// That is, the pending words aggregate to a full word, and the last split index is >16.
#[test]
fn test_concat_pending_sum_up_to_more_than_word_gt16() {
let ba1 = test_byte_array_30();
let ba2 = test_byte_array_30();
let ba3 = ByteArrayTrait::concat(@ba1, @ba2);
let expected_data = array![0x0102030405060708091a0b0c0d0e0f101112131415161718191a1b1c1d1e01];
compare_byte_array(
@ba3, expected_data.span(), 29, 0x02030405060708091a0b0c0d0e0f101112131415161718191a1b1c1d1e
);
}
#[test]
fn test_len() {
let ba: ByteArray = Default::default();
assert(ba.len() == 0, 'wrong ByteArray len');
let mut ba = test_byte_array_33();
assert(ba.len() == 33, 'wrong ByteArray len');
ba.append(@test_byte_array_30());
assert(ba.len() == 63, 'wrong ByteArray len');
}
#[test]
fn test_at_empty() {
let ba: ByteArray = Default::default();
assert(ba.at(0) == Option::None, 'index 0 is not out of bounds');
assert(ba.at(1) == Option::None, 'index 1 is not out of bounds');
assert(ba.at(30) == Option::None, 'index 30 is not out of bounds');
assert(ba.at(31) == Option::None, 'index 31 is not out of bounds');
}
#[test]
fn test_at() {
let mut ba = test_byte_array_31();
ba.append(@test_byte_array_31());
ba.append(@test_byte_array_17());
assert(ba.at(0) == Option::Some(0x01), 'wrong byte at index 0');
assert(ba.at(1) == Option::Some(0x02), 'wrong byte at index 1');
assert(ba.at(2) == Option::Some(0x03), 'wrong byte at index 2');
assert(ba.at(14) == Option::Some(0x0f), 'wrong byte at index 14');
assert(ba.at(15) == Option::Some(0x10), 'wrong byte at index 15');
assert(ba.at(16) == Option::Some(0x11), 'wrong byte at index 16');
assert(ba.at(17) == Option::Some(0x12), 'wrong byte at index 17');
assert(ba.at(29) == Option::Some(0x1e), 'wrong byte at index 29');
assert(ba.at(30) == Option::Some(0x1f), 'wrong byte at index 30');
assert(ba.at(31) == Option::Some(0x01), 'wrong byte at index 31');
assert(ba.at(32) == Option::Some(0x02), 'wrong byte at index 32');
assert(ba.at(61) == Option::Some(0x1f), 'wrong byte at index 61');
assert(ba.at(62) == Option::Some(0x01), 'wrong byte at index 62');
assert(ba.at(63) == Option::Some(0x02), 'wrong byte at index 63');
assert(ba.at(76) == Option::Some(0x0f), 'wrong byte at index 76');
assert(ba.at(77) == Option::Some(0x10), 'wrong byte at index 77');
assert(ba.at(78) == Option::Some(0x11), 'wrong byte at index 78');
assert(ba.at(79) == Option::None, 'index 79 is not out of bounds');
}
// Same as the previous test, but with [] instead of .at() (and without the out-of-bounds case).
#[test]
fn test_index_view() {
let mut ba = test_byte_array_31();
ba.append(@test_byte_array_31());
ba.append(@test_byte_array_17());
assert(ba[0] == 0x01, 'wrong byte at index 0');
assert(ba[1] == 0x02, 'wrong byte at index 1');
assert(ba[2] == 0x03, 'wrong byte at index 2');
assert(ba[14] == 0x0f, 'wrong byte at index 14');
assert(ba[15] == 0x10, 'wrong byte at index 15');
assert(ba[16] == 0x11, 'wrong byte at index 16');
assert(ba[17] == 0x12, 'wrong byte at index 17');
assert(ba[29] == 0x1e, 'wrong byte at index 29');
assert(ba[30] == 0x1f, 'wrong byte at index 30');
assert(ba[31] == 0x01, 'wrong byte at index 31');
assert(ba[32] == 0x02, 'wrong byte at index 32');
assert(ba[61] == 0x1f, 'wrong byte at index 61');
assert(ba[62] == 0x01, 'wrong byte at index 62');
assert(ba[63] == 0x02, 'wrong byte at index 63');
assert(ba[76] == 0x0f, 'wrong byte at index 76');
assert(ba[77] == 0x10, 'wrong byte at index 77');
assert(ba[78] == 0x11, 'wrong byte at index 78');
}
// Test panic with [] in case of out-of-bounds
#[test]
#[should_panic(expected: ('Index out of bounds',))]
fn test_index_view_out_of_bounds() {
let mut ba = test_byte_array_31();
ba.append(@test_byte_array_31());
ba.append(@test_byte_array_17());
let _x = ba[79];
}
#[test]
fn test_string_literals() {
let _ba: ByteArray = "12345"; // len < 16
let _ba: ByteArray = "1234567890123456"; // len == 16
let _ba: ByteArray = "123456789012345678"; // 16 < len < 31
let _ba: ByteArray = "1234567890123456789012345678901"; // len == 31
let _ba: ByteArray = "123456789012345678901234567890123"; // 31 < len < 47
let _ba: ByteArray = "12345678901234567890123456789012345678901234567"; // len == 47
let _ba: ByteArray = "123456789012345678901234567890123456789012345678"; // len > 47
}
#[test]
fn test_equality() {
let byte_array: ByteArray = "a";
assert(@byte_array == @"a", 'Same strings are not equal');
assert(@byte_array != @"b", 'Different strings are equal');
let mut ba1 = test_byte_array_2();
ba1.append(@test_byte_array_31());
let ba2 = test_byte_array_33();
let ba3 = test_byte_array_32();
let mut ba4 = test_byte_array_32();
ba4.append(@test_byte_array_1());
assert(@ba1 == @ba1, 'Same ByteArrays are not equal');
assert(@ba2 == @ba2, 'Same ByteArrays are not equal');
assert(@ba3 == @ba3, 'Same ByteArrays are not equal');
assert(@ba4 == @ba4, 'Same ByteArrays are not equal');
// Different data
assert(@ba1 != @ba2, 'Different ByteArrays are equal');
// Different pending word length
assert(@ba2 != @ba3, 'Different ByteArrays are equal');
// Different pending word
assert(@ba2 != @ba4, 'Different ByteArrays are equal');
}
#[test]
fn test_reverse() {
// Arrays of length < 16
let ba: ByteArray = "abc";
let ba_rev: ByteArray = "cba";
let palindrome: ByteArray = "rotator";
assert_ne(@ba, @ba.rev(), 'ba == ba.rev()');
assert_ne(@ba_rev, @ba_rev.rev(), 'ba_rev == ba_rev.rev()');
assert_eq(@ba, @ba_rev.rev(), 'ba != ba_rev.rev()');
assert_eq(@palindrome, @palindrome.rev(), 'palindrome is not a palindrome');
// Arrays of length 16
let ba: ByteArray = "my length is 16.";
let ba_rev: ByteArray = ".61 si htgnel ym";
let palindrome: ByteArray = "nolemon nomelon";
assert_ne(@ba, @ba.rev(), 'ba == ba.rev()');
assert_ne(@ba_rev, @ba_rev.rev(), 'ba_rev == ba_rev.rev()');
assert_eq(@ba, @ba_rev.rev(), 'ba != ba_rev.rev()');
assert_eq(@palindrome, @palindrome.rev(), 'palindrome is not a palindrome');
// Arrays of 16 < length < 31
let ba: ByteArray = "I am a medium byte array";
let ba_rev: ByteArray = "yarra etyb muidem a ma I";
let palindrome: ByteArray = "nolemon nomelon";
assert_ne(@ba, @ba.rev(), 'ba == ba.rev()');
assert_ne(@ba_rev, @ba_rev.rev(), 'ba_rev == ba_rev.rev()');
assert_eq(@ba, @ba_rev.rev(), 'ba != ba_rev.rev()');
assert_eq(@palindrome, @palindrome.rev(), 'palindrome is not a palindrome');
// Arrays of length 31
let ba: ByteArray = "I didn't find a good palindrome";
let ba_rev: ByteArray = "emordnilap doog a dnif t'ndid I";
let palindrome: ByteArray = "kayak level rotator level kayak";
assert_ne(@ba, @ba.rev(), 'ba == ba.rev()');
assert_ne(@ba_rev, @ba_rev.rev(), 'ba_rev == ba_rev.rev()');
assert_eq(@ba, @ba_rev.rev(), 'ba != ba_rev.rev()');
assert_eq(@palindrome, @palindrome.rev(), 'palindrome is not a palindrome');
// Arrays of 31 < length < 47 (31+16)
let ba: ByteArray = "This time I did find a good palindrome!";
let ba_rev: ByteArray = "!emordnilap doog a dnif did I emit sihT";
let palindrome: ByteArray = "noitneverpropagatesifisetagaporprevention";
assert_ne(@ba, @ba.rev(), 'ba == ba.rev()');
assert_ne(@ba_rev, @ba_rev.rev(), 'ba_rev == ba_rev.rev()');
assert_eq(@ba, @ba_rev.rev(), 'ba != ba_rev.rev()');
assert_eq(@palindrome, @palindrome.rev(), 'palindrome is not a palindrome');
// Arrays of length 47 (31+16)
let ba: ByteArray = "I have found a palindrome, exactly 47 in length";
let ba_rev: ByteArray = "htgnel ni 74 yltcaxe ,emordnilap a dnuof evah I";
let palindrome: ByteArray = "onacloverifaliveeruptsavastpureevilafirevolcano";
assert_ne(@ba, @ba.rev(), 'ba == ba.rev()');
assert_ne(@ba_rev, @ba_rev.rev(), 'ba_rev == ba_rev.rev()');
assert_eq(@ba, @ba_rev.rev(), 'ba != ba_rev.rev()');
assert_eq(@palindrome, @palindrome.rev(), 'palindrome is not a palindrome');
// Arrays of length > 47 (31+16)
let ba: ByteArray = "This palindrome is not as good, but at least it's long enough";
let ba_rev: ByteArray = "hguone gnol s'ti tsael ta tub ,doog sa ton si emordnilap sihT";
let palindrome: ByteArray = "docnoteidissentafastneverpreventsafatnessidietoncod";
assert_ne(@ba, @ba.rev(), 'ba == ba.rev()');
assert_ne(@ba_rev, @ba_rev.rev(), 'ba_rev == ba_rev.rev()');
assert_eq(@ba, @ba_rev.rev(), 'ba != ba_rev.rev()');
assert_eq(@palindrome, @palindrome.rev(), 'palindrome is not a palindrome');
}
#[test]
fn test_serde() {
let mut serialized = array![];
let ba: ByteArray = "";
let expected_serialized = array![0, 0, 0];
ba.serialize(ref serialized);
compare_spans(serialized.span(), expected_serialized.span());
let mut serialized = array![];
let ba: ByteArray = "hello";
let expected_serialized = array![
0, // data len
0x68656c6c6f, // pending_word
5 // pending_word_len
];
ba.serialize(ref serialized);
compare_spans(serialized.span(), expected_serialized.span());
let mut serialized = array![];
let ba: ByteArray = "Long string, more than 31 characters.";
let expected_serialized = array![
1, // data len
0x4c6f6e6720737472696e672c206d6f7265207468616e203331206368617261, // data
0x63746572732e, // pending_word
6 // pending_word_len
];
ba.serialize(ref serialized);
compare_spans(serialized.span(), expected_serialized.span());
}
// ========= Test helper functions =========
fn compare_byte_array(
mut ba: @ByteArray, mut data: Span<felt252>, pending_word_len: usize, pending_word: felt252
) {
assert(ba.data.len() == data.len(), 'wrong data len');
let mut ba_data = ba.data.span();
let mut data_index = 0;
loop {
match ba_data.pop_front() {
Option::Some(x) => {
let actual_word = (*x).into();
let expected_word = *data.pop_front().unwrap();
assert_eq!(actual_word, expected_word, "wrong data for index: {data_index}");
},
Option::None(_) => { break; }
}
data_index += 1;
};
assert_eq!(*ba.pending_word_len, pending_word_len);
let ba_pending_word_felt: felt252 = (*ba.pending_word).into();
assert_eq!(ba_pending_word_felt, pending_word);
}
fn compare_spans<T, +core::fmt::Debug<T>, +PartialEq<T>, +Copy<T>, +Drop<T>>(
mut a: Span<T>, mut b: Span<T>
) {
assert_eq!(a.len(), b.len());
let mut index = 0;
loop {
match a.pop_front() {
Option::Some(current_a) => {
let current_b = b.pop_front().unwrap();
assert_eq!(*current_a, *current_b, "wrong data for index: {index}");
},
Option::None(_) => { break; }
}
index += 1;
};
}
fn test_byte_array_1() -> ByteArray {
let mut ba1 = Default::default();
ba1.append_word(0x01, 1);
ba1
}
fn test_byte_array_2() -> ByteArray {
let mut ba1 = Default::default();
ba1.append_word(0x0102, 2);
ba1
}
fn test_byte_array_16() -> ByteArray {
let mut ba1 = Default::default();
ba1.append_word(0x0102030405060708091a0b0c0d0e0f10, 16);
ba1
}
fn test_byte_array_17() -> ByteArray {
let mut ba1 = Default::default();
ba1.append_word(0x0102030405060708091a0b0c0d0e0f1011, 17);
ba1
}
fn test_byte_array_30() -> ByteArray {
let mut ba1 = Default::default();
ba1.append_word(0x0102030405060708091a0b0c0d0e0f101112131415161718191a1b1c1d1e, 30);
ba1
}
fn test_byte_array_31() -> ByteArray {
let mut ba1 = Default::default();
ba1.append_word(0x0102030405060708091a0b0c0d0e0f101112131415161718191a1b1c1d1e1f, 31);
ba1
}
fn test_byte_array_32() -> ByteArray {
let mut ba1 = Default::default();
ba1.append_word(0x0102030405060708091a0b0c0d0e0f101112131415161718191a1b1c1d1e1f, 31);
ba1.append_word(0x20, 1);
ba1
}
fn test_byte_array_33() -> ByteArray {
let mut ba2 = Default::default();
ba2.append_word(0x0102030405060708091a0b0c0d0e0f101112131415161718191a1b1c1d1e1f, 31);
ba2.append_word(0x2021, 2);
ba2
}