aboutsummaryrefslogtreecommitdiffstats
path: root/test/src
diff options
context:
space:
mode:
authorLars Ingebrigtsen2020-09-25 01:52:10 +0200
committerLars Ingebrigtsen2020-09-25 01:53:16 +0200
commite51a98b0c2d35648c2d054486f7ba5869e24e4cf (patch)
treed4c261379c595b034663aa5b3c229e3bd64d99b3 /test/src
parente7a69c9204a2b208401b9368a70acad21022c7a3 (diff)
downloademacs-e51a98b0c2d35648c2d054486f7ba5869e24e4cf.tar.gz
emacs-e51a98b0c2d35648c2d054486f7ba5869e24e4cf.zip
Add a new function 'string-search'
* doc/lispref/strings.texi (Text Comparison): Document it. * src/fns.c (Fstring_search): New function.
Diffstat (limited to 'test/src')
-rw-r--r--test/src/fns-tests.el23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/src/fns-tests.el b/test/src/fns-tests.el
index b9a7d29895a..8c2b1300dce 100644
--- a/test/src/fns-tests.el
+++ b/test/src/fns-tests.el
@@ -901,3 +901,26 @@
901 (should (equal (delete t [nil t]) [nil])) 901 (should (equal (delete t [nil t]) [nil]))
902 (should (equal (delete 1 v1) (vector))) 902 (should (equal (delete 1 v1) (vector)))
903 (should (equal (delete 2 v1) v1)))) 903 (should (equal (delete 2 v1) v1))))
904
905(ert-deftest string-search ()
906 (should (equal (string-search "zot" "foobarzot") 6))
907 (should (equal (string-search "foo" "foobarzot") 0))
908 (should (not (string-search "fooz" "foobarzot")))
909 (should (not (string-search "zot" "foobarzo")))
910
911 (should (equal
912 (string-search (make-string 2 130)
913 (concat "helló" (make-string 5 130 t) "bár"))
914 5))
915 (should (equal
916 (string-search (make-string 2 127)
917 (concat "helló" (make-string 5 127 t) "bár"))
918 5))
919
920 (should (equal (string-search "\377" "a\377ø") 1))
921 (should (equal (string-search "\377" "a\377a") 1))
922
923 (should (not (string-search (make-string 1 255) "a\377ø")))
924 (should (not (string-search (make-string 1 255) "a\377a")))
925
926 (should (equal (string-search "fóo" "zotfóo") 3)))