;;; dir-var-test.el --- Directory variables -*- lexical-binding: t; -*- ;;; Copyright (C) 2023 BTuin ;;; Homepage: https://gitlab.com/btuin2/builder ;; This program is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . ;;; Commentary: ;;; This package provides tests for dir-var-el. ;;; Code: (require 'ert) ;; "require" does not work for some reason, "dir-var.el" is not found. ;; (require 'dir-var) (ert-deftest dir-var-set-variable-test () (should (equal (dir-var--set-node-variable (dir-var--set-node-variable (dir-var--make-node "name") 'var "test") 'var "value") '("name" nil (var "value"))))) (ert-deftest dir-var-insert-variable-test () (should (equal (dir-var--insert-variable (dir-var--insert-variable (dir-var--make-node "test") (list "1" "2" "3" "4") 'var1 "value1") (list "1" "2" "5") 'var2 "value2") '("test" (("1" (("2" (("5" nil (var2 "value2")) ("3" (("4" nil (var1 "value1"))))))))))))) (ert-deftest dir-var-remove-variable-test () (should (equal (dir-var--remove-variable (dir-var--insert-variable (dir-var--insert-variable (dir-var--make-node "test") (list "1" "2" "3" "4") 'var1 "value1") (list "1" "2" "5") 'var2 "value2") (list "1" "2" "3" "4") 'var1) '("test" (("1" (("2" (("5" nil (var2 "value2"))))))))))) (ert-deftest dir-var-get-variable-test () (let ((tree (dir-var--make-node "test"))) (setq tree (dir-var--insert-variable tree (list "1" "2" "3" "4") 'var1 "value1")) (setq tree (dir-var--insert-variable tree (list "1" "2" "5") 'var2 "value2")) (setq tree (dir-var--insert-variable tree (list "1" "2" "3") 'var3 "value3")) (should (equal (dir-var--variable-get-value tree (list "1" "2" "3" "4") 'var1) "value1")) (should (equal (dir-var--variable-get-value tree (list "1" "2" "5") 'var2) "value2")) (should (equal (dir-var--variable-get-value tree (list "1" "2" "3" "4") 'var3) "value3")) (should (equal (dir-var--variable-get-value tree (list "1" "2" "5") 'var3) nil)))) (provide 'dir-var-test) ;;; dir-var-test.el ends here