Mercurial > hgrepos > FreeBSD > ports > sysutils > local-bsdtools
diff tests/farray-array.t @ 596:1b40b875b281
farray.sh: farray_set() now accepts general indices
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Wed, 18 Sep 2024 16:44:47 +0200 |
| parents | 4babcf9abc1a |
| children | 46ff12cfeed0 |
line wrap: on
line diff
--- a/tests/farray-array.t Wed Sep 18 16:15:19 2024 +0200 +++ b/tests/farray-array.t Wed Sep 18 16:44:47 2024 +0200 @@ -236,6 +236,101 @@ $ check_no_array_artifacts +Setting +======= + +Append (relative) + + $ farray_create TEST 0 1 2 '3 4 5' $'" 678" \\\'910 ' 11 + $ farray_set TEST "" $'the new value \\ \'' + $ farray_debug TEST + DEBUG: array `TEST' has length 7 + DEBUG: its contents: + DEBUG: 1: `0' + DEBUG: 2: `1' + DEBUG: 3: `2' + DEBUG: 4: `3 4 5' + DEBUG: 5: `" 678" \'910 ' + DEBUG: 6: `11' + DEBUG: 7: `the new value \ '' + $ farray_destroy TEST + $ check_no_array_artifacts + +Append (explicit) + + $ farray_create TEST 0 1 2 '3 4 5' $'" 678" \\\'910 ' 11 + $ farray_set TEST 7 $'the new value \\ \'' + $ farray_debug TEST + DEBUG: array `TEST' has length 7 + DEBUG: its contents: + DEBUG: 1: `0' + DEBUG: 2: `1' + DEBUG: 3: `2' + DEBUG: 4: `3 4 5' + DEBUG: 5: `" 678" \'910 ' + DEBUG: 6: `11' + DEBUG: 7: `the new value \ '' + $ farray_destroy TEST + $ check_no_array_artifacts + +Replace the last element + + $ farray_create TEST 0 1 2 '3 4 5' $'" 678" \\\'910 ' 11 + $ farray_set TEST 0 $'the new replaced value \\ \'' + $ farray_debug TEST + DEBUG: array `TEST' has length 6 + DEBUG: its contents: + DEBUG: 1: `0' + DEBUG: 2: `1' + DEBUG: 3: `2' + DEBUG: 4: `3 4 5' + DEBUG: 5: `" 678" \'910 ' + DEBUG: 6: `the new replaced value \ '' + $ farray_destroy TEST + $ check_no_array_artifacts + +Replace the first element + + $ farray_create TEST 0 1 2 '3 4 5' $'" 678" \\\'910 ' 11 + $ farray_set TEST 1 $'the new replaced value \\ \'' + $ farray_debug TEST + DEBUG: array `TEST' has length 6 + DEBUG: its contents: + DEBUG: 1: `the new replaced value \ '' + DEBUG: 2: `1' + DEBUG: 3: `2' + DEBUG: 4: `3 4 5' + DEBUG: 5: `" 678" \'910 ' + DEBUG: 6: `11' + $ farray_destroy TEST + $ check_no_array_artifacts + +Replace some element in the middle + + $ farray_create TEST 0 1 2 '3 4 5' $'" 678" \\\'910 ' 11 + $ farray_set TEST 5 $'the new replaced value \\ \' 2 ' + $ farray_debug TEST + DEBUG: array `TEST' has length 6 + DEBUG: its contents: + DEBUG: 1: `0' + DEBUG: 2: `1' + DEBUG: 3: `2' + DEBUG: 4: `3 4 5' + DEBUG: 5: `the new replaced value \ ' 2 ' + DEBUG: 6: `11' + $ farray_destroy TEST + $ check_no_array_artifacts + +Out of bounds + + $ farray_create TEST 0 1 2 '3 4 5' $'" 678" \\\'910 ' 11 + $ ( farray_set TEST 8 ) + ERROR: array index out of bounds (cannot create holes) + [70] + $ farray_destroy TEST + $ check_no_array_artifacts + + Splicing ========
