comparison tests/farray-array.t @ 764:711c0a11d642

farray.sh: Implement farray_insert()
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 21 Oct 2024 15:38:01 +0200
parents 7ead30e3b2f9
children 54fefbabcf78
comparison
equal deleted inserted replaced
763:9ded61e89712 764:711c0a11d642
346 [70] 346 [70]
347 $ farray_release TEST 347 $ farray_release TEST
348 $ check_no_array_artifacts 348 $ check_no_array_artifacts
349 349
350 350
351 Inserting
352 =========
353
354 Append
355
356 $ farray_create TEST 0 1 2 '3 4 5' $'" 678" \\\'910 ' 11
357 $ farray_insert TEST "" $'the new appended value \\ \''
358 $ farray_debug TEST
359 DEBUG: array `TEST' has length 7
360 DEBUG: the items:
361 DEBUG: 1: `0'
362 DEBUG: 2: `1'
363 DEBUG: 3: `2'
364 DEBUG: 4: `3 4 5'
365 DEBUG: 5: `" 678" \'910 '
366 DEBUG: 6: `11'
367 DEBUG: 7: `the new appended value \ ''
368 $ farray_release TEST
369 $ check_no_array_artifacts
370
371 Prepend
372
373 $ farray_create TEST 0 1 2 '3 4 5' $'" 678" \\\'910 ' 11
374 $ farray_insert TEST 1 $'the new prepended value \\ \''
375 $ farray_debug TEST
376 DEBUG: array `TEST' has length 7
377 DEBUG: the items:
378 DEBUG: 1: `the new prepended value \ ''
379 DEBUG: 2: `0'
380 DEBUG: 3: `1'
381 DEBUG: 4: `2'
382 DEBUG: 5: `3 4 5'
383 DEBUG: 6: `" 678" \'910 '
384 DEBUG: 7: `11'
385 $ farray_release TEST
386 $ check_no_array_artifacts
387
388 In the middle
389
390 $ farray_create TEST 0 1 2 '3 4 5' $'" 678" \\\'910 ' 11
391 $ farray_insert TEST 2 $'the new inserted value \\ \''
392 $ farray_debug TEST
393 DEBUG: array `TEST' has length 7
394 DEBUG: the items:
395 DEBUG: 1: `0'
396 DEBUG: 2: `the new inserted value \ ''
397 DEBUG: 3: `1'
398 DEBUG: 4: `2'
399 DEBUG: 5: `3 4 5'
400 DEBUG: 6: `" 678" \'910 '
401 DEBUG: 7: `11'
402 $ farray_release TEST
403 $ check_no_array_artifacts
404
405 Out of bounds
406
407 $ farray_create TEST 0 1 2 '3 4 5' $'" 678" \\\'910 ' 11
408 $ (farray_insert TEST 8 $'the new inserted value \\ \'')
409 ERROR: array index out of bounds
410 [70]
411 $ farray_release TEST
412 $ check_no_array_artifacts
413
414 Missing value
415
416 $ farray_create TEST 0 1 2 '3 4 5' $'" 678" \\\'910 ' 11
417 $ (farray_insert TEST 0)
418 ERROR: missing value to insert
419 [70]
420 $ farray_release TEST
421 $ check_no_array_artifacts
422
351 Splicing 423 Splicing
352 ======== 424 ========
353 425
354 Replace complete array 426 Replace complete array
355 427