For example, here are two versions of a function for counting instances of βaβ in a region or row:
(defun foo (beg end) (interactive "r") (let ((count 0)) (save-excursion (while (/= (point) end) (if (equal (char-after) ?a) (setq count (1+ count))) (forward-char))) count)) (defun foo1 (str) (let ((count 0)) (mapcar
This is a test for checking the function foo1 :
(require 'ert) (ert-deftest foo-test () (should (equal (foo1 "aba") 2)))
but how can I test a function foo that accepts a region as input using the ert unit testing framework?
source share