about summary refs log tree commit diff
path: root/users/wpcarro/emacs/pkgs/struct/tests.el
diff options
context:
space:
mode:
Diffstat (limited to 'users/wpcarro/emacs/pkgs/struct/tests.el')
-rw-r--r--users/wpcarro/emacs/pkgs/struct/tests.el42
1 files changed, 31 insertions, 11 deletions
diff --git a/users/wpcarro/emacs/pkgs/struct/tests.el b/users/wpcarro/emacs/pkgs/struct/tests.el
index ee48c2f6b5d1..a7ddb52c46d6 100644
--- a/users/wpcarro/emacs/pkgs/struct/tests.el
+++ b/users/wpcarro/emacs/pkgs/struct/tests.el
@@ -3,22 +3,42 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 (require 'ert)
-(require 'dash)
 (require 'struct)
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Tests
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
-(ert-deftest struct-set! ()
-  (cl-defstruct dummy name age)
-  (defvar struct--test-dummy (make-dummy :name "Roofus" :age 19))
-  (struct-set! dummy name "Doofus" struct--test-dummy)
-  (should (string= "Doofus" (dummy-name struct--test-dummy))))
+(cl-defstruct dummy name age)
+
+(ert-deftest struct-update ()
+  (let* ((test (make-dummy :name "Roofus" :age 19))
+         (result (struct-update dummy name #'upcase test)))
+    ;; test
+    (should (string= "Roofus" (dummy-name test)))
+    (should (= 19 (dummy-age test)))
+    ;; result
+    (should (string= "ROOFUS" (dummy-name result)))
+    (should (= 19 (dummy-age result)))))
+
+(ert-deftest struct-update! ()
+  (let ((test (make-dummy :name "Roofus" :age 19)))
+    (struct-update! dummy name #'upcase test)
+    (should (string= "ROOFUS" (dummy-name test)))
+    (should (= 19 (dummy-age test)))))
 
 (ert-deftest struct-set ()
-  (cl-defstruct dummy name age)
-  (defvar struct--test-dummy (make-dummy :name "Roofus" :age 19))
-  (let ((result (struct-set dummy name "Shoofus" struct--test-dummy)))
-    (should (string= "Roofus" (dummy-name struct--test-dummy)))
-    (should (string= "Shoofus" (dummy-name result)))))
+  (let* ((test (make-dummy :name "Roofus" :age 19))
+         (result (struct-set dummy name "Shoofus" test)))
+    ;; test
+    (should (string= "Roofus" (dummy-name test)))
+    (should (= 19 (dummy-age test)))
+    ;; result
+    (should (string= "Shoofus" (dummy-name result)))
+    (should (= 19 (dummy-age result)))))
+
+(ert-deftest struct-set! ()
+  (let ((test (make-dummy :name "Roofus" :age 19)))
+    (struct-set! dummy name "Doofus" test)
+    (should (string= "Doofus" (dummy-name test)))
+    (should (= 19 (dummy-age test)))))