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).
This commit is contained in:
parent
556ae6674c
commit
67ed6ee733
2 changed files with 28 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue