diff options
| author | Philip Kaludercic | 2021-09-23 18:12:41 +0200 |
|---|---|---|
| committer | Mattias Engdegård | 2021-09-23 19:10:38 +0200 |
| commit | c44190ca5b9873fceae8aee7034ce8e89c42d4dd (patch) | |
| tree | 43a7d5ec8023ef2c7476ced38886ad78df92cf24 /test/src | |
| parent | 13d930deddd2e0529a0fb0f2fb93dd621d6d35be (diff) | |
| download | emacs-c44190ca5b9873fceae8aee7034ce8e89c42d4dd.tar.gz emacs-c44190ca5b9873fceae8aee7034ce8e89c42d4dd.zip | |
Fix string-distance for two empty strings
* fns.c (Fstring_distance): Avoid using uninitialized memory.
* test/src/fns-tests.el (test-string-distance): Add test cases.
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/fns-tests.el | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/test/src/fns-tests.el b/test/src/fns-tests.el index 9f6593a177c..bd5a4358e65 100644 --- a/test/src/fns-tests.el +++ b/test/src/fns-tests.el | |||
| @@ -786,7 +786,15 @@ | |||
| 786 | ;; string containing hanzi character, compare by character | 786 | ;; string containing hanzi character, compare by character |
| 787 | (should (equal 2 (string-distance "ab" "ab我她"))) | 787 | (should (equal 2 (string-distance "ab" "ab我她"))) |
| 788 | (should (equal 1 (string-distance "ab" "a我b"))) | 788 | (should (equal 1 (string-distance "ab" "a我b"))) |
| 789 | (should (equal 1 (string-distance "我" "她")))) | 789 | (should (equal 1 (string-distance "我" "她"))) |
| 790 | |||
| 791 | ;; correct behaviour with empty strings | ||
| 792 | (should (equal 0 (string-distance "" ""))) | ||
| 793 | (should (equal 0 (string-distance "" "" t))) | ||
| 794 | (should (equal 1 (string-distance "x" ""))) | ||
| 795 | (should (equal 1 (string-distance "x" "" t))) | ||
| 796 | (should (equal 1 (string-distance "" "x"))) | ||
| 797 | (should (equal 1 (string-distance "" "x" t)))) | ||
| 790 | 798 | ||
| 791 | (ert-deftest test-bignum-eql () | 799 | (ert-deftest test-bignum-eql () |
| 792 | "Test that `eql' works for bignums." | 800 | "Test that `eql' works for bignums." |