aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorChen Bin2018-04-20 00:38:29 +1000
committerEli Zaretskii2018-04-28 09:56:14 +0300
commitc6e6503900534d939dd94b812563c27f22c49b7d (patch)
tree4fd31046412e32e6475e43497bf94040ef79975e /test
parent4bc74dac281ff2a502fc89e76f6210dc711cfed1 (diff)
downloademacs-c6e6503900534d939dd94b812563c27f22c49b7d.tar.gz
emacs-c6e6503900534d939dd94b812563c27f22c49b7d.zip
New function 'string-distance'
* src/fns.c (Fstring_distance): New primitive. (syms_of_fns): Defsubr it. * test/lisp/subr-tests.el (subr-tests--string-distance): New test. * etc/NEWS: Mention 'string-distance'.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/subr-tests.el18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el
index 52b61d9fb97..6b80c743a05 100644
--- a/test/lisp/subr-tests.el
+++ b/test/lisp/subr-tests.el
@@ -281,6 +281,24 @@ indirectly `mapbacktrace'."
281 (should (equal (string-match-p "\\`[[:blank:]]\\'" "\u3000") 0)) 281 (should (equal (string-match-p "\\`[[:blank:]]\\'" "\u3000") 0))
282 (should-not (string-match-p "\\`[[:blank:]]\\'" "\N{LINE SEPARATOR}"))) 282 (should-not (string-match-p "\\`[[:blank:]]\\'" "\N{LINE SEPARATOR}")))
283 283
284(ert-deftest subr-tests--string-distance ()
285 "Test `string-distance' behavior."
286 ;; ASCII characters are always fine
287 (should (equal 1 (string-distance "heelo" "hello")))
288 (should (equal 2 (string-distance "aeelo" "hello")))
289 (should (equal 0 (string-distance "ab" "ab" t)))
290 (should (equal 1 (string-distance "ab" "abc" t)))
291
292 ;; string containing hanzi character, compare by byte
293 (should (equal 6 (string-distance "ab" "ab我她" t)))
294 (should (equal 3 (string-distance "ab" "a我b" t)))
295 (should (equal 3 (string-distance "我" "她" t)))
296
297 ;; string containing hanzi character, compare by character
298 (should (equal 2 (string-distance "ab" "ab我她")))
299 (should (equal 1 (string-distance "ab" "a我b")))
300 (should (equal 1 (string-distance "我" "她"))))
301
284(ert-deftest subr-tests--dolist--wrong-number-of-args () 302(ert-deftest subr-tests--dolist--wrong-number-of-args ()
285 "Test that `dolist' doesn't accept wrong types or length of SPEC, 303 "Test that `dolist' doesn't accept wrong types or length of SPEC,
286cf. Bug#25477." 304cf. Bug#25477."