Fix tp-search-map tests to use same-length replacements

Use upcase for string test to avoid truncation issues with
fixed-length Emacs strings.

Co-authored-by: Kinneyzhang <38454496+Kinneyzhang@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2025-12-15 15:29:42 +00:00
parent e88337ff1f
commit b2fb5e75c5

View File

@ -862,16 +862,17 @@
(tp-set 4 7 '(marker t) str) (tp-set 4 7 '(marker t) str)
(tp-set 8 11 '(marker t) str) (tp-set 8 11 '(marker t) str)
;; Use a function that accepts idx and records the indices ;; Use a function that accepts idx and records the indices
;; Return the uppercased text (same length) to avoid truncation issues
(tp-search-map (lambda (txt idx) (tp-search-map (lambda (txt idx)
(push idx indices) (push idx indices)
(format "%d:%s" idx txt)) (upcase txt))
str 'marker) str 'marker)
;; Check indices were passed in order (reversed due to push) ;; Check indices were passed in order (reversed due to push)
(should (equal (reverse indices) '(0 1 2))) (should (equal (reverse indices) '(0 1 2)))
;; Check text was transformed with index ;; Check text was transformed (uppercased)
(should (equal (substring str 0 5) "0:aaa")) (should (equal (substring str 0 3) "AAA"))
(should (equal (substring str 4 9) "1:bbb")) (should (equal (substring str 4 7) "BBB"))
(should (equal (substring str 8 13) "2:ccc")))) (should (equal (substring str 8 11) "CCC"))))
(ert-deftest tp-test-search-map-with-idx-in-buffer () (ert-deftest tp-test-search-map-with-idx-in-buffer ()
"Test tp-search-map passes index to function in buffer range." "Test tp-search-map passes index to function in buffer range."