| ... | ... | @@ -266,19 +266,36 @@ test "insert ArrayList test" { |
| 266 | 266 | defer list.deinit(); |
| 267 | 267 | |
| 268 | 268 | try list.append(1); |
| 269 | try list.append(2); |
| 270 | try list.append(3); |
| 269 | 271 | try list.insert(0, 5); |
| 270 | 272 | assert(list.items[0] == 5); |
| 271 | 273 | assert(list.items[1] == 1); |
| 274 | assert(list.items[2] == 2); |
| 275 | assert(list.items[3] == 3); |
| 276 | } |
| 277 | |
| 278 | test "insertSlice ArrayList test" { |
| 279 | var list = ArrayList(i32).init(debug.global_allocator); |
| 280 | defer list.deinit(); |
| 272 | 281 | |
| 282 | try list.append(1); |
| 283 | try list.append(2); |
| 284 | try list.append(3); |
| 285 | try list.append(4); |
| 273 | 286 | try list.insertSlice(1, []const i32{ |
| 274 | 287 | 9, |
| 275 | 288 | 8, |
| 276 | 289 | }); |
| 277 | | assert(list.items[0] == 5); |
| 290 | assert(list.items[0] == 1); |
| 278 | 291 | assert(list.items[1] == 9); |
| 279 | 292 | assert(list.items[2] == 8); |
| 293 | assert(list.items[3] == 2); |
| 294 | assert(list.items[4] == 3); |
| 295 | assert(list.items[5] == 4); |
| 280 | 296 | |
| 281 | 297 | const items = []const i32{1}; |
| 282 | 298 | try list.insertSlice(0, items[0..0]); |
| 283 | | assert(list.items[0] == 5); |
| 299 | assert(list.len == 6); |
| 300 | assert(list.items[0] == 1); |
| 284 | 301 | } |