annotate tests/automated/search-tests.el @ 5633:49c36ed998b6

No longer use the obsolete function names, hash-table-tests.el tests/ChangeLog addition: 2011-12-30 Aidan Kehoe <kehoea@parhasard.net> * automated/hash-table-tests.el: No longer use the obsolete function names in the tests, now they've been removed from cl.el.
author Aidan Kehoe <kehoea@parhasard.net>
date Fri, 30 Dec 2011 16:39:14 +0000
parents 308d34e9f07d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4902
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
1 ;;; -*- coding: iso-8859-1 -*-
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
2
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
3 ;; Copyright (C) 2000 Free Software Foundation, Inc.
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
4 ;; Copyright (C) 2010 Ben Wing.
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
5
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
6 ;; Author: Yoshiki Hayashi <yoshiki@xemacs.org>
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
7 ;; Maintainer: Yoshiki Hayashi <yoshiki@xemacs.org>
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
8 ;; Created: 2000
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
9 ;; Keywords: tests
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
10
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
11 ;; This file is part of XEmacs.
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
12
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5136
diff changeset
13 ;; XEmacs is free software: you can redistribute it and/or modify it
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5136
diff changeset
14 ;; under the terms of the GNU General Public License as published by the
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5136
diff changeset
15 ;; Free Software Foundation, either version 3 of the License, or (at your
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5136
diff changeset
16 ;; option) any later version.
4902
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
17
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5136
diff changeset
18 ;; XEmacs is distributed in the hope that it will be useful, but WITHOUT
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5136
diff changeset
19 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5136
diff changeset
20 ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5136
diff changeset
21 ;; for more details.
4902
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
22
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
23 ;; You should have received a copy of the GNU General Public License
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5136
diff changeset
24 ;; along with XEmacs. If not, see <http://www.gnu.org/licenses/>.
4902
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
25
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
26 ;;; Synched up with: Not in FSF.
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
27
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
28 ;;; Commentary:
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
29
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
30 ;; Test of non-regexp searching.
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
31
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
32 ;; Split out of case-tests.el.
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
33
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
34 ;; NOTE NOTE NOTE: See also:
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
35 ;;
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
36 ;; (1) regexp-tests.el, for regexp searching.
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
37 ;; (2) case-tests.el, for some case-related searches.
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
38
4906
6ef8256a020a implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents: 4902
diff changeset
39 ;; NOTE NOTE NOTE: There is some domain overlap among case-tests.el,
6ef8256a020a implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents: 4902
diff changeset
40 ;; regexp-tests.el and search-tests.el. See case-tests.el.
4902
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
41
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
42 (with-temp-buffer
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
43 (insert "Test Buffer")
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
44 (let ((case-fold-search t))
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
45 (goto-char (point-min))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5041
diff changeset
46 (Assert (eq (search-forward "test buffer" nil t) 12))
4902
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
47 (goto-char (point-min))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5041
diff changeset
48 (Assert (eq (search-forward "Test buffer" nil t) 12))
4902
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
49 (goto-char (point-min))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5041
diff changeset
50 (Assert (eq (search-forward "Test Buffer" nil t) 12))
4902
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
51
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
52 (setq case-fold-search nil)
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
53 (goto-char (point-min))
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
54 (Assert (not (search-forward "test buffer" nil t)))
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
55 (goto-char (point-min))
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
56 (Assert (not (search-forward "Test buffer" nil t)))
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
57 (goto-char (point-min))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5041
diff changeset
58 (Assert (eq (search-forward "Test Buffer" nil t) 12))))
4902
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
59
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
60 (with-temp-buffer
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
61 (insert "abcdefghijklmnäopqrstuÄvwxyz")
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
62 ;; case insensitive
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
63 (Assert (not (search-forward "ö" nil t)))
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
64 (goto-char (point-min))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5041
diff changeset
65 (Assert (eq 16 (search-forward "ä" nil t)))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5041
diff changeset
66 (Assert (eq 24 (search-forward "ä" nil t)))
4902
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
67 (goto-char (point-min))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5041
diff changeset
68 (Assert (eq 16 (search-forward "Ä" nil t)))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5041
diff changeset
69 (Assert (eq 24 (search-forward "Ä" nil t)))
4902
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
70 (goto-char (point-max))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5041
diff changeset
71 (Assert (eq 23 (search-backward "ä" nil t)))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5041
diff changeset
72 (Assert (eq 15 (search-backward "ä" nil t)))
4902
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
73 (goto-char (point-max))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5041
diff changeset
74 (Assert (eq 23 (search-backward "Ä" nil t)))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5041
diff changeset
75 (Assert (eq 15 (search-backward "Ä" nil t)))
4902
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
76 ;; case sensitive
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
77 (setq case-fold-search nil)
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
78 (goto-char (point-min))
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
79 (Assert (not (search-forward "ö" nil t)))
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
80 (goto-char (point-min))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5041
diff changeset
81 (Assert (eq 16 (search-forward "ä" nil t)))
4902
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
82 (Assert (not (search-forward "ä" nil t)))
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
83 (goto-char (point-min))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5041
diff changeset
84 (Assert (eq 24 (search-forward "Ä" nil t)))
4902
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
85 (goto-char 16)
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5041
diff changeset
86 (Assert (eq 24 (search-forward "Ä" nil t)))
4902
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
87 (goto-char (point-max))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5041
diff changeset
88 (Assert (eq 15 (search-backward "ä" nil t)))
4902
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
89 (goto-char 15)
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
90 (Assert (not (search-backward "ä" nil t)))
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
91 (goto-char (point-max))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5041
diff changeset
92 (Assert (eq 23 (search-backward "Ä" nil t)))
4902
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
93 (Assert (not (search-backward "Ä" nil t))))
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
94
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
95 (with-temp-buffer
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
96 (insert "aaaaäÄäÄäÄäÄäÄbbbb")
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
97 (goto-char (point-min))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5041
diff changeset
98 (Assert (eq 15 (search-forward "ää" nil t 5)))
4902
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
99 (goto-char (point-min))
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
100 (Assert (not (search-forward "ää" nil t 6)))
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
101 (goto-char (point-max))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5041
diff changeset
102 (Assert (eq 5 (search-backward "ää" nil t 5)))
4902
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
103 (goto-char (point-max))
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
104 (Assert (not (search-backward "ää" nil t 6))))
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
105
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
106 (when (featurep 'mule)
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
107 (let* ((hiragana-a (make-char 'japanese-jisx0208 36 34))
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
108 (a-diaeresis ?ä)
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
109 (case-table (copy-case-table (standard-case-table)))
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
110 (str-hiragana-a (char-to-string hiragana-a))
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
111 (str-a-diaeresis (char-to-string a-diaeresis))
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
112 (string (concat str-hiragana-a str-a-diaeresis)))
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
113 (put-case-table-pair hiragana-a a-diaeresis case-table)
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
114 (with-temp-buffer
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
115 (set-case-table case-table)
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
116 (insert hiragana-a "abcdefg" a-diaeresis)
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
117 ;; forward
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
118 (goto-char (point-min))
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
119 (Assert (not (search-forward "ö" nil t)))
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
120 (goto-char (point-min))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5041
diff changeset
121 (Assert (eq 2 (search-forward str-hiragana-a nil t)))
4902
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
122 (goto-char (point-min))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5041
diff changeset
123 (Assert (eq 2 (search-forward str-a-diaeresis nil t)))
4902
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
124 (goto-char (1+ (point-min)))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5041
diff changeset
125 (Assert (eq (point-max)
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5041
diff changeset
126 (search-forward str-hiragana-a nil t)))
4902
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
127 (goto-char (1+ (point-min)))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5041
diff changeset
128 (Assert (eq (point-max)
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5041
diff changeset
129 (search-forward str-a-diaeresis nil t)))
4902
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
130 ;; backward
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
131 (goto-char (point-max))
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
132 (Assert (not (search-backward "ö" nil t)))
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
133 (goto-char (point-max))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5041
diff changeset
134 (Assert (eq (1- (point-max)) (search-backward str-hiragana-a nil t)))
4902
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
135 (goto-char (point-max))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5041
diff changeset
136 (Assert (eq (1- (point-max)) (search-backward str-a-diaeresis nil t)))
4902
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
137 (goto-char (1- (point-max)))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5041
diff changeset
138 (Assert (eq 1 (search-backward str-hiragana-a nil t)))
4902
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
139 (goto-char (1- (point-max)))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5041
diff changeset
140 (Assert (eq 1 (search-backward str-a-diaeresis nil t)))
4902
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
141 (replace-match "a")
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
142 (Assert (looking-at (format "abcdefg%c" a-diaeresis))))
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
143 (with-temp-buffer
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
144 (set-case-table case-table)
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
145 (insert string)
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
146 (insert string)
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
147 (insert string)
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
148 (insert string)
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
149 (insert string)
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
150 (goto-char (point-min))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5041
diff changeset
151 (Assert (eq 11 (search-forward string nil t 5)))
4902
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
152 (goto-char (point-min))
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
153 (Assert (not (search-forward string nil t 6)))
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
154 (goto-char (point-max))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5041
diff changeset
155 (Assert (eq 1 (search-backward string nil t 5)))
4902
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
156 (goto-char (point-max))
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
157 (Assert (not (search-backward string nil t 6))))))
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
158
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
159 ;; Bug reported in http://mid.gmane.org/y9lk5lu5orq.fsf@deinprogramm.de from
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
160 ;; Michael Sperber. Fixed 2008-01-29.
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
161 (with-string-as-buffer-contents "\n\nDer beruhmte deutsche Flei\xdf\n\n"
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
162 (goto-char (point-min))
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
163 (Assert (search-forward "Flei\xdf")))
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
164
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
165 (with-temp-buffer
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
166 (let ((target "M\xe9zard")
5041
efaa6cd845e5 add regexp-debugging
Ben Wing <ben@xemacs.org>
parents: 4907
diff changeset
167 (debug-searches 1))
4902
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
168 (Assert (not (search-forward target nil t)))
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
169 (insert target)
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
170 (goto-char (point-min))
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
171 ;; #### search-algorithm-used is simple-search after the following,
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
172 ;; which shouldn't be necessary; it should be possible to use
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
173 ;; Boyer-Moore.
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
174 ;;
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
175 ;; But searches for ASCII strings in buffers with nothing above ?\xFF
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
176 ;; use Boyer Moore with the current implementation, which is the
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
177 ;; important thing for the Gnus use case.
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5041
diff changeset
178 (Assert (= (1+ (length target)) (search-forward target nil t)))))
4902
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
179
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
180 (Skip-Test-Unless
5041
efaa6cd845e5 add regexp-debugging
Ben Wing <ben@xemacs.org>
parents: 4907
diff changeset
181 (boundp 'debug-searches) ; normal when we have DEBUG_XEMACS
4902
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
182 "not a DEBUG_XEMACS build"
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
183 "checks that the algorithm chosen by #'search-forward is relatively sane"
5041
efaa6cd845e5 add regexp-debugging
Ben Wing <ben@xemacs.org>
parents: 4907
diff changeset
184 (let ((debug-searches 1)
4904
e91e3e353805 Don't compare the same octet with itself if checking for boyer_moore_ok
Aidan Kehoe <kehoea@parhasard.net>
parents: 4902
diff changeset
185 newcase)
4902
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
186 (with-temp-buffer
4904
e91e3e353805 Don't compare the same octet with itself if checking for boyer_moore_ok
Aidan Kehoe <kehoea@parhasard.net>
parents: 4902
diff changeset
187 (insert "\n\nDer beruehmte deutsche Fleiss\n\n")
4902
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
188 (goto-char (point-min))
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
189 (Assert (search-forward "Fleiss"))
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
190 (delete-region (point-min) (point-max))
4904
e91e3e353805 Don't compare the same octet with itself if checking for boyer_moore_ok
Aidan Kehoe <kehoea@parhasard.net>
parents: 4902
diff changeset
191 (insert "\n\nDer ber\xfchmte deutsche Flei\xdf\n\n")
4902
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
192 (goto-char (point-min))
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
193 (Assert (search-forward "Flei\xdf"))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5041
diff changeset
194 (Assert (eq 'boyer-moore search-algorithm-used))
4902
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
195 (delete-region (point-min) (point-max))
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
196 (when (featurep 'mule)
4904
e91e3e353805 Don't compare the same octet with itself if checking for boyer_moore_ok
Aidan Kehoe <kehoea@parhasard.net>
parents: 4902
diff changeset
197 (insert "\n\nDer ber\xfchmte deutsche Flei\xdf\n\n")
4902
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
198 (goto-char (point-min))
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
199 (Assert
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
200 (search-forward (format "Fle%c\xdf"
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
201 (make-char 'latin-iso8859-9 #xfd))))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5041
diff changeset
202 (Assert (eq 'boyer-moore search-algorithm-used))
4902
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
203 (insert (make-char 'latin-iso8859-9 #xfd))
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
204 (goto-char (point-min))
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
205 (Assert (search-forward "Flei\xdf"))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5041
diff changeset
206 (Assert (eq 'simple-search search-algorithm-used))
4902
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
207 (goto-char (point-min))
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
208 (Assert (search-forward (format "Fle%c\xdf"
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
209 (make-char 'latin-iso8859-9 #xfd))))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5041
diff changeset
210 (Assert (eq 'simple-search search-algorithm-used))
4904
e91e3e353805 Don't compare the same octet with itself if checking for boyer_moore_ok
Aidan Kehoe <kehoea@parhasard.net>
parents: 4902
diff changeset
211 (setq newcase (copy-case-table (standard-case-table)))
e91e3e353805 Don't compare the same octet with itself if checking for boyer_moore_ok
Aidan Kehoe <kehoea@parhasard.net>
parents: 4902
diff changeset
212 (put-case-table-pair (make-char 'ethiopic #x23 #x23)
e91e3e353805 Don't compare the same octet with itself if checking for boyer_moore_ok
Aidan Kehoe <kehoea@parhasard.net>
parents: 4902
diff changeset
213 (make-char 'ethiopic #x23 #x25)
e91e3e353805 Don't compare the same octet with itself if checking for boyer_moore_ok
Aidan Kehoe <kehoea@parhasard.net>
parents: 4902
diff changeset
214 newcase)
e91e3e353805 Don't compare the same octet with itself if checking for boyer_moore_ok
Aidan Kehoe <kehoea@parhasard.net>
parents: 4902
diff changeset
215 (with-case-table
e91e3e353805 Don't compare the same octet with itself if checking for boyer_moore_ok
Aidan Kehoe <kehoea@parhasard.net>
parents: 4902
diff changeset
216 ;; Check that when a multidimensional character has case and two
e91e3e353805 Don't compare the same octet with itself if checking for boyer_moore_ok
Aidan Kehoe <kehoea@parhasard.net>
parents: 4902
diff changeset
217 ;; repeating octets, searches involving it in the search pattern
e91e3e353805 Don't compare the same octet with itself if checking for boyer_moore_ok
Aidan Kehoe <kehoea@parhasard.net>
parents: 4902
diff changeset
218 ;; use simple-search; otherwise boyer_moore() gets confused in the
e91e3e353805 Don't compare the same octet with itself if checking for boyer_moore_ok
Aidan Kehoe <kehoea@parhasard.net>
parents: 4902
diff changeset
219 ;; construction of the stride table.
e91e3e353805 Don't compare the same octet with itself if checking for boyer_moore_ok
Aidan Kehoe <kehoea@parhasard.net>
parents: 4902
diff changeset
220 newcase
e91e3e353805 Don't compare the same octet with itself if checking for boyer_moore_ok
Aidan Kehoe <kehoea@parhasard.net>
parents: 4902
diff changeset
221 (delete-region (point-min) (point-max))
e91e3e353805 Don't compare the same octet with itself if checking for boyer_moore_ok
Aidan Kehoe <kehoea@parhasard.net>
parents: 4902
diff changeset
222 (insert ?0)
e91e3e353805 Don't compare the same octet with itself if checking for boyer_moore_ok
Aidan Kehoe <kehoea@parhasard.net>
parents: 4902
diff changeset
223 (insert (make-char 'ethiopic #x23 #x23))
e91e3e353805 Don't compare the same octet with itself if checking for boyer_moore_ok
Aidan Kehoe <kehoea@parhasard.net>
parents: 4902
diff changeset
224 (insert ?1)
e91e3e353805 Don't compare the same octet with itself if checking for boyer_moore_ok
Aidan Kehoe <kehoea@parhasard.net>
parents: 4902
diff changeset
225 (goto-char (point-min))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5041
diff changeset
226 (Assert (eql (search-forward
4904
e91e3e353805 Don't compare the same octet with itself if checking for boyer_moore_ok
Aidan Kehoe <kehoea@parhasard.net>
parents: 4902
diff changeset
227 (string (make-char 'ethiopic #x23 #x25))
e91e3e353805 Don't compare the same octet with itself if checking for boyer_moore_ok
Aidan Kehoe <kehoea@parhasard.net>
parents: 4902
diff changeset
228 nil t)
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5041
diff changeset
229 3))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5041
diff changeset
230 (Assert (eq 'simple-search search-algorithm-used))
4904
e91e3e353805 Don't compare the same octet with itself if checking for boyer_moore_ok
Aidan Kehoe <kehoea@parhasard.net>
parents: 4902
diff changeset
231 (goto-char (point-min))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5041
diff changeset
232 (Assert (eql (search-forward
4904
e91e3e353805 Don't compare the same octet with itself if checking for boyer_moore_ok
Aidan Kehoe <kehoea@parhasard.net>
parents: 4902
diff changeset
233 (string (make-char 'ethiopic #x23 #x27))
e91e3e353805 Don't compare the same octet with itself if checking for boyer_moore_ok
Aidan Kehoe <kehoea@parhasard.net>
parents: 4902
diff changeset
234 nil t)
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5041
diff changeset
235 nil))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5041
diff changeset
236 (Assert (eq 'boyer-moore search-algorithm-used)))))))
4902
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
237
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
238 ;; XEmacs bug of long standing.
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
239
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
240 (with-temp-buffer
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
241 (insert "foo\201bar")
c902301f8b7d fix CRLF line endings in search-tests.el
Ben Wing <ben@xemacs.org>
parents: 4897
diff changeset
242 (goto-char (point-min))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5041
diff changeset
243 (Assert (eq (search-forward "\201" nil t) 5)))