From 51f5c4b773e11dd50f9fc6887362324b6d4dc755 Mon Sep 17 00:00:00 2001
From: Lars Ingebrigtsen <larsi@gnus.org>
Date: Sat, 23 Jul 2022 08:55:20 +0200
Subject: Fix off-by-one error in string-truncate-left

* lisp/emacs-lisp/subr-x.el (string-truncate-left): Fix off-by-one
error (bug#56685).
---
 test/lisp/emacs-lisp/subr-x-tests.el | 5 +++++
 1 file changed, 5 insertions(+)

(limited to 'test/lisp/emacs-lisp')

diff --git a/test/lisp/emacs-lisp/subr-x-tests.el b/test/lisp/emacs-lisp/subr-x-tests.el
index 99c0e822155..7a3efe9db62 100644
--- a/test/lisp/emacs-lisp/subr-x-tests.el
+++ b/test/lisp/emacs-lisp/subr-x-tests.el
@@ -766,5 +766,10 @@
     (should (equal (sort (hash-table-keys h) #'string<) '(a b c)))
     (should (equal (sort (hash-table-values h) #'<) '(1 2 3)))))
 
+(ert-deftest test-string-truncate-left ()
+  (should (equal (string-truncate-left "band" 3) "...d"))
+  (should (equal (string-truncate-left "band" 2) "...d"))
+  (should (equal (string-truncate-left "longstring" 8) "...tring")))
+
 (provide 'subr-x-tests)
 ;;; subr-x-tests.el ends here
-- 
cgit v1.2.3