diff tests/farray-alist.t @ 614:62fbc4316d97

farray.sh: Implement falist_update(): update an existing alist from another
author Franz Glasner <fzglas.hg@dom66.de>
date Thu, 19 Sep 2024 22:20:02 +0200
parents 17194ffe3638
children 454ce7fa25c8
line wrap: on
line diff
--- a/tests/farray-alist.t	Thu Sep 19 20:03:29 2024 +0200
+++ b/tests/farray-alist.t	Thu Sep 19 22:20:02 2024 +0200
@@ -273,4 +273,46 @@
   $ falist_destroy LIST3
   $ falist_destroy LIST4
 
+  $ check_no_alist_artifacts
+
+
+Updating
+========
+
+  $ falist_create ARR "Key 1" "Value 1" "Key 2" 'Value 2 '\'''
+  $ falist_create UPDATE1 "Key 1" "Value 1" "Key 2" 'Value 2 '\'''
+  $ falist_create UPDATE2 "Key 2" 'Value 2 (Updated) '\''' "Key 3" "Value 3"
+  $ falist_create EMPTY
+
+  $ falist_are_equal_with_order ARR UPDATE1
+  $ falist_are_equal_with_order ARR UPDATE2
+  [1]
+
+  $ falist_update ARR UPDATE1
+  $ falist_are_equal_with_order ARR UPDATE1
+
+  $ falist_update ARR UPDATE2
+  $ falist_debug ARR
+  DEBUG: alist `ARR' has length 3
+  DEBUG:     `Key 1' -> `Value 1'
+  DEBUG:     `Key 2' -> `Value 2 (Updated) ''
+  DEBUG:     `Key 3' -> `Value 3'
+
+Updating an into an empty alist is just a copy
+
+  $ falist_update EMPTY UPDATE1
+  $ falist_debug EMPTY
+  DEBUG: alist `EMPTY' has length 2
+  DEBUG:     `Key 1' -> `Value 1'
+  DEBUG:     `Key 2' -> `Value 2 ''
+  $ falist_debug UPDATE1
+  DEBUG: alist `UPDATE1' has length 2
+  DEBUG:     `Key 1' -> `Value 1'
+  DEBUG:     `Key 2' -> `Value 2 ''
+
+  $ falist_destroy ARR
+  $ falist_destroy UPDATE1
+  $ falist_destroy UPDATE2
+  $ falist_destroy EMPTY
+
   $ check_no_alist_artifacts
\ No newline at end of file