diff options
| author | Mattias EngdegÄrd | 2019-10-10 21:20:20 +0200 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2019-10-13 20:29:27 +0200 |
| commit | 67ed6ee7337d66dc1101e41bc2e67bde5ab0ecd4 (patch) | |
| tree | 2ab9cbaee0cd98bd3a01d496c91e6ca4fda041dd /lisp | |
| parent | 556ae6674c600e19453a43de51817aa8b4df52fa (diff) | |
| download | emacs-67ed6ee7337d66dc1101e41bc2e67bde5ab0ecd4.tar.gz 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')
| -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." | |||
| 516 | (cl-assert (equal a b) t) | 516 | (cl-assert (equal a b) t) |
| 517 | nil)))))))) | 517 | nil)))))))) |
| 518 | ((pred arrayp) | 518 | ((pred arrayp) |
| 519 | ;; For mixed unibyte/multibyte string comparisons, make both multibyte. | ||
| 520 | (when (and (stringp a) | ||
| 521 | (xor (multibyte-string-p a) (multibyte-string-p b))) | ||
| 522 | (setq a (string-to-multibyte a)) | ||
| 523 | (setq b (string-to-multibyte b))) | ||
| 519 | (if (/= (length a) (length b)) | 524 | (if (/= (length a) (length b)) |
| 520 | `(arrays-of-different-length ,(length a) ,(length b) | 525 | `(arrays-of-different-length ,(length a) ,(length b) |
| 521 | ,a ,b | 526 | ,a ,b |