annotate tests/farray-alist.t @ 607:c450fd0eaddb

farray.sh: Generalized indices for falist_tryget_{item,key,value}_at_index()
author Franz Glasner <fzglas.hg@dom66.de>
date Thu, 19 Sep 2024 12:21:58 +0200
parents 0ad7b2120e74
children c9ef2339618d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
604
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
1 Basic tests of farray.sh's falist_XXX functions
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
2
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
3 Shell is /bin/sh.
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
4
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
5
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
6 Setup
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
7 =====
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
8
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
9 $ set -u
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
10 $ . "${TESTDIR}/testsetup.sh"
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
11 $ _p_datadir="${TESTDIR}/../share/local-bsdtools"
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
12 $ . "${_p_datadir}/farray.sh"
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
13
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
14
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
15 Basic Creation and Destruction
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
16 ==============================
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
17
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
18 Create an empty alist
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
19
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
20 $ falist_create LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
21 $ falist_length _i LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
22 $ echo "$_i"
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
23 0
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
24 $ test "${_i}" -eq 0
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
25 $ falist_print_length LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
26 0 (no-eol)
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
27
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
28 $ falist_debug LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
29 DEBUG: alist `LIST' has length 0
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
30
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
31 $ falist_destroy LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
32 $ ( falist_destroy LIST )
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
33 ERROR: falist `LIST' not created properly: token empty
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
34 [1]
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
35
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
36 $ check_no_alist_artifacts
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
37
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
38
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
39 Clear
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
40 =====
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
41
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
42 $ falist_create LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
43 $ falist_set LIST K1 V1
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
44 $ falist_set LIST K2 V2
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
45 $ falist_debug LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
46 DEBUG: alist `LIST' has length 2
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
47 DEBUG: `K1' -> `V1'
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
48 DEBUG: `K2' -> `V2'
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
49 $ falist_length _i LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
50 $ echo "$_i"
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
51 2
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
52 $ falist_print_length LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
53 2 (no-eol)
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
54
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
55 $ falist_clear LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
56 $ falist_length _i LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
57 $ echo "$_i"
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
58 0
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
59 $ falist_print_length LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
60 0 (no-eol)
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
61
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
62 $ falist_destroy LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
63 $ check_no_alist_artifacts
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
64
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
65
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
66 Get / Set / Contains
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
67 ====================
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
68
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
69 $ falist_create LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
70 $ falist_set LIST K1 V1
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
71 $ falist_set LIST K2 V2
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
72 $ falist_debug LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
73 DEBUG: alist `LIST' has length 2
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
74 DEBUG: `K1' -> `V1'
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
75 DEBUG: `K2' -> `V2'
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
76 $ falist_length _i LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
77 $ echo "$_i"
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
78 2
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
79 $ falist_print_length LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
80 2 (no-eol)
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
81
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
82 $ falist_set LIST K2 "V2 2"
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
83 $ falist_set LIST K3 $'" 111222333" \\\'444555 ' # '
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
84 $ falist_debug LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
85 DEBUG: alist `LIST' has length 3
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
86 DEBUG: `K1' -> `V1'
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
87 DEBUG: `K2' -> `V2 2'
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
88 DEBUG: `K3' -> `" 111222333" \'444555 '
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
89 $ falist_length _i LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
90 $ echo "$_i"
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
91 3
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
92 $ falist_print_length LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
93 3 (no-eol)
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
94
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
95 $ falist_contains LIST K1
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
96 $ falist_contains LIST K
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
97 [1]
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
98 $ falist_get _var LIST K2
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
99 $ echo "$_var"
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
100 V2 2
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
101 $ falist_tryget _var LIST K1
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
102 $ echo "$_var"
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
103 V1
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
104 $ falist_tryget _i LIST K
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
105 [1]
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
106 $ _var="$(falist_print_length NON_EXISTING_LIST)"
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
107 ERROR: falist `NON_EXISTING_LIST' not created properly: token empty
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
108 $ echo "${_var}"
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
109 -1
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
110
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
111 $ falist_destroy LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
112 $ check_no_alist_artifacts
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
113
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
114
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
115 Iteration
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
116 =========
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
117
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
118 ITERATE (manual indexing)
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
119
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
120 $ falist_create LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
121 $ falist_set LIST K1 V1
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
122 $ falist_set LIST K2 "V2 2"
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
123 $ falist_set LIST K3 $'" 111222333" \\\'444555 ' # '
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
124
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
125 Iteration by indexing key and values separately
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
126
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
127 $ _i=1
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
128 > while falist_tryget_key_at_index _k LIST ${_i}; do
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
129 > # cannot fail under "normal" circumstances
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
130 > falist_tryget_value_at_index _v LIST ${_i}
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
131 > printf " KEY: \`%s', VAL: \`%s'\\n" "${_k}" "${_v}"
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
132 > _i=$((_i + 1))
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
133 > done
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
134 KEY: `K1', VAL: `V1'
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
135 KEY: `K2', VAL: `V2 2'
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
136 KEY: `K3', VAL: `" 111222333" \'444555 '
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
137
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
138 ITERATE (manual indexing over items)
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
139
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
140 $ _i=1
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
141 > while falist_tryget_item_at_index _k _v LIST ${_i}; do
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
142 > printf " KEY: \`%s', VAL: \`%s'\\n" "${_k}" "${_v}"
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
143 > _i=$((_i + 1))
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
144 > done
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
145 KEY: `K1', VAL: `V1'
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
146 KEY: `K2', VAL: `V2 2'
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
147 KEY: `K3', VAL: `" 111222333" \'444555 '
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
148
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
149 ITERATE (for each)
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
150
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
151 $ falist_for_each LIST $'printf "EACH: %s key \\`%s\\\', value \\`%s\\\' at idx %d\\n"' # `
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
152 EACH: LIST key `K1', value `V1' at idx 1
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
153 EACH: LIST key `K2', value `V2 2' at idx 2
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
154 EACH: LIST key `K3', value `" 111222333" \'444555 ' at idx 3
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
155
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
156 $ falist_clear LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
157 $ falist_destroy LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
158 $ falist_destroy LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
159 ERROR: falist `LIST' not created properly: token empty
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
160 [1]
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
161
606
0ad7b2120e74 farray.sh: tests: add forgotten check for left artifacts (memory leaks)
Franz Glasner <fzglas.hg@dom66.de>
parents: 605
diff changeset
162 $ check_no_alist_artifacts
0ad7b2120e74 farray.sh: tests: add forgotten check for left artifacts (memory leaks)
Franz Glasner <fzglas.hg@dom66.de>
parents: 605
diff changeset
163
604
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
164
607
c450fd0eaddb farray.sh: Generalized indices for falist_tryget_{item,key,value}_at_index()
Franz Glasner <fzglas.hg@dom66.de>
parents: 606
diff changeset
165 Valid and Invalid Indices
c450fd0eaddb farray.sh: Generalized indices for falist_tryget_{item,key,value}_at_index()
Franz Glasner <fzglas.hg@dom66.de>
parents: 606
diff changeset
166
c450fd0eaddb farray.sh: Generalized indices for falist_tryget_{item,key,value}_at_index()
Franz Glasner <fzglas.hg@dom66.de>
parents: 606
diff changeset
167 $ falist_create LIST
c450fd0eaddb farray.sh: Generalized indices for falist_tryget_{item,key,value}_at_index()
Franz Glasner <fzglas.hg@dom66.de>
parents: 606
diff changeset
168 $ falist_set LIST 'KEY 1' 'VAL 1'
c450fd0eaddb farray.sh: Generalized indices for falist_tryget_{item,key,value}_at_index()
Franz Glasner <fzglas.hg@dom66.de>
parents: 606
diff changeset
169 $ falist_set LIST 'KEY 2' 'VAL 2'
c450fd0eaddb farray.sh: Generalized indices for falist_tryget_{item,key,value}_at_index()
Franz Glasner <fzglas.hg@dom66.de>
parents: 606
diff changeset
170 $ falist_set LIST 'KEY 3' 'VAL 3'
c450fd0eaddb farray.sh: Generalized indices for falist_tryget_{item,key,value}_at_index()
Franz Glasner <fzglas.hg@dom66.de>
parents: 606
diff changeset
171
c450fd0eaddb farray.sh: Generalized indices for falist_tryget_{item,key,value}_at_index()
Franz Glasner <fzglas.hg@dom66.de>
parents: 606
diff changeset
172 $ (falist_tryget_item_at_index _k _v LIST "")
c450fd0eaddb farray.sh: Generalized indices for falist_tryget_{item,key,value}_at_index()
Franz Glasner <fzglas.hg@dom66.de>
parents: 606
diff changeset
173 ERROR: missing index
c450fd0eaddb farray.sh: Generalized indices for falist_tryget_{item,key,value}_at_index()
Franz Glasner <fzglas.hg@dom66.de>
parents: 606
diff changeset
174 [70]
c450fd0eaddb farray.sh: Generalized indices for falist_tryget_{item,key,value}_at_index()
Franz Glasner <fzglas.hg@dom66.de>
parents: 606
diff changeset
175
c450fd0eaddb farray.sh: Generalized indices for falist_tryget_{item,key,value}_at_index()
Franz Glasner <fzglas.hg@dom66.de>
parents: 606
diff changeset
176 $ (falist_tryget_item_at_index _k _v LIST)
c450fd0eaddb farray.sh: Generalized indices for falist_tryget_{item,key,value}_at_index()
Franz Glasner <fzglas.hg@dom66.de>
parents: 606
diff changeset
177 ERROR: missing index
c450fd0eaddb farray.sh: Generalized indices for falist_tryget_{item,key,value}_at_index()
Franz Glasner <fzglas.hg@dom66.de>
parents: 606
diff changeset
178 [70]
c450fd0eaddb farray.sh: Generalized indices for falist_tryget_{item,key,value}_at_index()
Franz Glasner <fzglas.hg@dom66.de>
parents: 606
diff changeset
179
c450fd0eaddb farray.sh: Generalized indices for falist_tryget_{item,key,value}_at_index()
Franz Glasner <fzglas.hg@dom66.de>
parents: 606
diff changeset
180 $ falist_tryget_item_at_index _k _v LIST 4
c450fd0eaddb farray.sh: Generalized indices for falist_tryget_{item,key,value}_at_index()
Franz Glasner <fzglas.hg@dom66.de>
parents: 606
diff changeset
181 [1]
c450fd0eaddb farray.sh: Generalized indices for falist_tryget_{item,key,value}_at_index()
Franz Glasner <fzglas.hg@dom66.de>
parents: 606
diff changeset
182
c450fd0eaddb farray.sh: Generalized indices for falist_tryget_{item,key,value}_at_index()
Franz Glasner <fzglas.hg@dom66.de>
parents: 606
diff changeset
183 $ falist_tryget_item_at_index _k _v LIST 0
c450fd0eaddb farray.sh: Generalized indices for falist_tryget_{item,key,value}_at_index()
Franz Glasner <fzglas.hg@dom66.de>
parents: 606
diff changeset
184 $ printf '%s:%s' "$_k" "$_v"
c450fd0eaddb farray.sh: Generalized indices for falist_tryget_{item,key,value}_at_index()
Franz Glasner <fzglas.hg@dom66.de>
parents: 606
diff changeset
185 KEY 3:VAL 3 (no-eol)
c450fd0eaddb farray.sh: Generalized indices for falist_tryget_{item,key,value}_at_index()
Franz Glasner <fzglas.hg@dom66.de>
parents: 606
diff changeset
186
c450fd0eaddb farray.sh: Generalized indices for falist_tryget_{item,key,value}_at_index()
Franz Glasner <fzglas.hg@dom66.de>
parents: 606
diff changeset
187 $ falist_tryget_item_at_index _k _v LIST -2
c450fd0eaddb farray.sh: Generalized indices for falist_tryget_{item,key,value}_at_index()
Franz Glasner <fzglas.hg@dom66.de>
parents: 606
diff changeset
188 $ printf '%s:%s' "$_k" "$_v"
c450fd0eaddb farray.sh: Generalized indices for falist_tryget_{item,key,value}_at_index()
Franz Glasner <fzglas.hg@dom66.de>
parents: 606
diff changeset
189 KEY 1:VAL 1 (no-eol)
c450fd0eaddb farray.sh: Generalized indices for falist_tryget_{item,key,value}_at_index()
Franz Glasner <fzglas.hg@dom66.de>
parents: 606
diff changeset
190
c450fd0eaddb farray.sh: Generalized indices for falist_tryget_{item,key,value}_at_index()
Franz Glasner <fzglas.hg@dom66.de>
parents: 606
diff changeset
191 $ falist_tryget_item_at_index _k _v LIST -3
c450fd0eaddb farray.sh: Generalized indices for falist_tryget_{item,key,value}_at_index()
Franz Glasner <fzglas.hg@dom66.de>
parents: 606
diff changeset
192 [1]
c450fd0eaddb farray.sh: Generalized indices for falist_tryget_{item,key,value}_at_index()
Franz Glasner <fzglas.hg@dom66.de>
parents: 606
diff changeset
193
c450fd0eaddb farray.sh: Generalized indices for falist_tryget_{item,key,value}_at_index()
Franz Glasner <fzglas.hg@dom66.de>
parents: 606
diff changeset
194 $ falist_destroy LIST
c450fd0eaddb farray.sh: Generalized indices for falist_tryget_{item,key,value}_at_index()
Franz Glasner <fzglas.hg@dom66.de>
parents: 606
diff changeset
195 $ check_no_alist_artifacts
c450fd0eaddb farray.sh: Generalized indices for falist_tryget_{item,key,value}_at_index()
Franz Glasner <fzglas.hg@dom66.de>
parents: 606
diff changeset
196
c450fd0eaddb farray.sh: Generalized indices for falist_tryget_{item,key,value}_at_index()
Franz Glasner <fzglas.hg@dom66.de>
parents: 606
diff changeset
197
604
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
198 Deletion of keys
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
199 ================
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
200
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
201 $ falist_create LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
202 $ falist_set LIST 'key 1' 'value 1'
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
203 $ falist_set LIST 'key 2' 'value 2'
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
204 $ falist_set LIST 'key 3' 'value 3'
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
205 $ falist_set LIST 'key 4' 'value 4'
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
206 $ falist_set LIST 'key 5' 'value 5'
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
207 $ falist_trydel LIST 'key 1'
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
208 $ falist_trydel LIST 'key 5'
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
209 $ falist_trydel LIST 'key 3'
605
96366e2075fe farray.sh: enhance unittests for alists
Franz Glasner <fzglas.hg@dom66.de>
parents: 604
diff changeset
210 $ falist_debug LIST
96366e2075fe farray.sh: enhance unittests for alists
Franz Glasner <fzglas.hg@dom66.de>
parents: 604
diff changeset
211 DEBUG: alist `LIST' has length 2
96366e2075fe farray.sh: enhance unittests for alists
Franz Glasner <fzglas.hg@dom66.de>
parents: 604
diff changeset
212 DEBUG: `key 2' -> `value 2'
96366e2075fe farray.sh: enhance unittests for alists
Franz Glasner <fzglas.hg@dom66.de>
parents: 604
diff changeset
213 DEBUG: `key 4' -> `value 4'
604
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
214 $ falist_trydel LIST "non-existing key"
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
215 [1]
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
216 $ falist_print_length LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
217 2 (no-eol)
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
218 $ falist_get _var LIST 'key 2'
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
219 $ printf '%s' "$_var"
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
220 value 2 (no-eol)
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
221 $ falist_get _var LIST 'key 4'
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
222 $ printf '%s' "$_var"
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
223 value 4 (no-eol)
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
224
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
225 $ falist_destroy LIST
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
226
45c47bc1f7d2 farray.sh: Moved all currently existing tests for alists into cram tests.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
227 $ check_no_alist_artifacts