[emacs] A test

This commit is contained in:
John Doty 2025-05-22 18:57:22 +00:00
parent 548d493c8c
commit 1d1fc38354

View file

@ -710,7 +710,7 @@ If AT-END is non-nil, insert at end of line, otherwise at beginning."
:description "Buffer name or file path") :description "Buffer name or file path")
(:name "line_number" (:name "line_number"
:type integer :type integer
:description "Line to insert at") :description "1-based index of line to insert at")
(:name "text" (:name "text"
:type string :type string
:description "Text to insert") :description "Text to insert")
@ -722,6 +722,23 @@ If AT-END is non-nil, insert at end of line, otherwise at beginning."
:confirm t :confirm t
:include t) :include t)
(ert-deftest doty-tools--test--emacs_insert_line ()
"Tests for the emacs_insert_line tool."
(with-temp-buffer
(doty-tools--test--invoke-tool
"emacs_insert_at_line" (list :buffer_or_file (buffer-name)
:line_number 1
:text "Hello"))
(should (equal "Hello" (buffer-string)))
(doty-tools--test--invoke-tool
"emacs_insert_at_line" (list :buffer_or_file (buffer-name)
:line_number 1
:text " world!"
:at_end t))
(should (equal "Hello world!" (buffer-string)))))
(defun doty-tools--replace-text (buffer-or-file from-text to-text use-regex replace-all) (defun doty-tools--replace-text (buffer-or-file from-text to-text use-regex replace-all)
"Replace occurrences of FROM-TEXT with TO-TEXT in BUFFER-OR-FILE. "Replace occurrences of FROM-TEXT with TO-TEXT in BUFFER-OR-FILE.
If USE-REGEX is non-nil, treat FROM-TEXT as a regular expression. If USE-REGEX is non-nil, treat FROM-TEXT as a regular expression.