diff options
author | Mattias EngdegÄrd <mattiase@acm.org> | 2019-10-10 21:20:20 +0200 |
---|---|---|
committer | Mattias EngdegÄrd <mattiase@acm.org> | 2019-10-13 20:29:27 +0200 |
commit | 67ed6ee7337d66dc1101e41bc2e67bde5ab0ecd4 (patch) | |
tree | 2ab9cbaee0cd98bd3a01d496c91e6ca4fda041dd /lisp/emacs-lisp | |
parent | 556ae6674c600e19453a43de51817aa8b4df52fa (diff) | |
download | emacs-67ed6ee7337d66dc1101e41bc2e67bde5ab0ecd4.tar.gz emacs-67ed6ee7337d66dc1101e41bc2e67bde5ab0ecd4.tar.bz2 emacs-67ed6ee7337d66dc1101e41bc2e67bde5ab0ecd4.zip |
Correctly explain test failures with mixed uni/multibyte strings
* lisp/emacs-lisp/ert.el (ert--explain-equal-rec):
* test/lisp/emacs-lisp/ert-tests.el (ert-test-explain-equal):
When explaining a difference between a unibyte and a multibyte string,
first convert both to multibyte. Otherwise, we might end up comparing
unibyte char C to multibyte char C, 127<C<256, and not detect the
difference (bug#30219).
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r-- | lisp/emacs-lisp/ert.el | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lisp/emacs-lisp/ert.el b/lisp/emacs-lisp/ert.el index 68762b0752c..47d20cb69e8 100644 --- a/lisp/emacs-lisp/ert.el +++ b/lisp/emacs-lisp/ert.el @@ -516,6 +516,11 @@ Returns nil if they are." (cl-assert (equal a b) t) nil)))))))) ((pred arrayp) + ;; For mixed unibyte/multibyte string comparisons, make both multibyte. + (when (and (stringp a) + (xor (multibyte-string-p a) (multibyte-string-p b))) + (setq a (string-to-multibyte a)) + (setq b (string-to-multibyte b))) (if (/= (length a) (length b)) `(arrays-of-different-length ,(length a) ,(length b) ,a ,b |