diff options
author | Leon Rische <leon.rische@me.com> | 2022-11-30 13:19:24 +0100 |
---|---|---|
committer | Leon Rische <leon.rische@me.com> | 2022-11-30 13:19:24 +0100 |
commit | 073bfef99533d444103995f2dcf9c16b23506e70 (patch) | |
tree | ae82b52e23a9fffbd21ea942f7c187fab6216bfe /tests/org-fc-test-helper.el | |
parent | 44876305b38e11ac253817549a4271f926721c1e (diff) |
Update and refactor indexer tests
Diffstat (limited to 'tests/org-fc-test-helper.el')
-rw-r--r-- | tests/org-fc-test-helper.el | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/org-fc-test-helper.el b/tests/org-fc-test-helper.el index ea94198..789f847 100644 --- a/tests/org-fc-test-helper.el +++ b/tests/org-fc-test-helper.el @@ -1,3 +1,5 @@ +(require 'cl) + (defun org-fc-test-fixture (name) "Return the full path of fixture file NAME." (expand-file-name @@ -10,4 +12,28 @@ (lambda (card) (plist-get card :id)) index)) +(defun org-fc-test-check-structure (expected got) + "Check structural equality of parts of larger objects. +For plists, values of all keys in EXPECTED are compared, +lists are compared element-by-element, +everything else is checked for equality." + (cond + ;; plist + ((and (listp expected) + expected + (symbolp (car expected))) + (let ((keys + (cl-loop for key in expected by #'cddr collecting key))) + (dolist (key keys) + (org-fc-test-check-structure + (plist-get expected key) + (plist-get got key))))) + ;; Normal list + ((listp expected) + (should (eq (length expected) (length got))) + (cl-loop for e in expected for g in got do + (org-fc-test-check-structure e g))) + ;; Anything else + (t (should (equal expected got))))) + (provide 'org-fc-test-helper) |