comparison tests/automated/search-tests.el @ 4904:e91e3e353805

Don't compare the same octet with itself if checking for boyer_moore_ok src/ChangeLog addition: 2010-01-31 Aidan Kehoe <kehoea@parhasard.net> * search.c (search_buffer): When checking the octets of c for identity, don't compare the same octet with itself. Thank you Ben Wing! tests/ChangeLog addition: 2010-01-31 Aidan Kehoe <kehoea@parhasard.net> * automated/search-tests.el: Check that multidimensional characters with repeated octets and case information force simple_search(), since boyer_moore() doesn't understand them when constructing its stride table. In passing; correct my spelling. * automated/case-tests.el (uni-mappings): In passing; delete a couple of redundant tests, correct the logic of another.
author Aidan Kehoe <kehoea@parhasard.net>
date Sun, 31 Jan 2010 18:09:57 +0000
parents c902301f8b7d
children 9e7f5a77cc84
comparison
equal deleted inserted replaced
4903:70089046adef 4904:e91e3e353805
190 190
191 (Skip-Test-Unless 191 (Skip-Test-Unless
192 (boundp 'debug-xemacs-searches) ; normal when we have DEBUG_XEMACS 192 (boundp 'debug-xemacs-searches) ; normal when we have DEBUG_XEMACS
193 "not a DEBUG_XEMACS build" 193 "not a DEBUG_XEMACS build"
194 "checks that the algorithm chosen by #'search-forward is relatively sane" 194 "checks that the algorithm chosen by #'search-forward is relatively sane"
195 (let ((debug-xemacs-searches 1)) 195 (let ((debug-xemacs-searches 1)
196 newcase)
196 (with-temp-buffer 197 (with-temp-buffer
197 ;;#### Ben thinks this is unnecessary. with-temp-buffer creates 198 ;;#### Ben thinks this is unnecessary. with-temp-buffer creates
198 ;;a new buffer, which automatically inherits the standard case table. 199 ;;a new buffer, which automatically inherits the standard case table.
199 ;;(set-case-table pristine-case-table) 200 ;;(set-case-table pristine-case-table)
200 (insert "\n\nDer beruhmte deutsche Fleiss\n\n") 201 (insert "\n\nDer beruehmte deutsche Fleiss\n\n")
201 (goto-char (point-min)) 202 (goto-char (point-min))
202 (Assert (search-forward "Fleiss")) 203 (Assert (search-forward "Fleiss"))
203 (delete-region (point-min) (point-max)) 204 (delete-region (point-min) (point-max))
204 (insert "\n\nDer beruhmte deutsche Flei\xdf\n\n") 205 (insert "\n\nDer ber\xfchmte deutsche Flei\xdf\n\n")
205 (goto-char (point-min)) 206 (goto-char (point-min))
206 (Assert (search-forward "Flei\xdf")) 207 (Assert (search-forward "Flei\xdf"))
207 (Assert-eq 'boyer-moore search-algorithm-used) 208 (Assert-eq 'boyer-moore search-algorithm-used)
208 (delete-region (point-min) (point-max)) 209 (delete-region (point-min) (point-max))
209 (when (featurep 'mule) 210 (when (featurep 'mule)
210 (insert "\n\nDer beruhmte deutsche Flei\xdf\n\n") 211 (insert "\n\nDer ber\xfchmte deutsche Flei\xdf\n\n")
211 (goto-char (point-min)) 212 (goto-char (point-min))
212 (Assert 213 (Assert
213 (search-forward (format "Fle%c\xdf" 214 (search-forward (format "Fle%c\xdf"
214 (make-char 'latin-iso8859-9 #xfd)))) 215 (make-char 'latin-iso8859-9 #xfd))))
215 (Assert-eq 'boyer-moore search-algorithm-used) 216 (Assert-eq 'boyer-moore search-algorithm-used)
218 (Assert (search-forward "Flei\xdf")) 219 (Assert (search-forward "Flei\xdf"))
219 (Assert-eq 'simple-search search-algorithm-used) 220 (Assert-eq 'simple-search search-algorithm-used)
220 (goto-char (point-min)) 221 (goto-char (point-min))
221 (Assert (search-forward (format "Fle%c\xdf" 222 (Assert (search-forward (format "Fle%c\xdf"
222 (make-char 'latin-iso8859-9 #xfd)))) 223 (make-char 'latin-iso8859-9 #xfd))))
223 (Assert-eq 'simple-search search-algorithm-used))))) 224 (Assert-eq 'simple-search search-algorithm-used)
224 225 (setq newcase (copy-case-table (standard-case-table)))
226 (put-case-table-pair (make-char 'ethiopic #x23 #x23)
227 (make-char 'ethiopic #x23 #x25)
228 newcase)
229 (with-case-table
230 ;; Check that when a multidimensional character has case and two
231 ;; repeating octets, searches involving it in the search pattern
232 ;; use simple-search; otherwise boyer_moore() gets confused in the
233 ;; construction of the stride table.
234 newcase
235 (delete-region (point-min) (point-max))
236 (insert ?0)
237 (insert (make-char 'ethiopic #x23 #x23))
238 (insert ?1)
239 (goto-char (point-min))
240 (Assert-eql (search-forward
241 (string (make-char 'ethiopic #x23 #x25))
242 nil t)
243 3)
244 (Assert-eq 'simple-search search-algorithm-used)
245 (goto-char (point-min))
246 (Assert-eql (search-forward
247 (string (make-char 'ethiopic #x23 #x27))
248 nil t)
249 nil)
250 (Assert-eq 'boyer-moore search-algorithm-used))))))
225 251
226 ;; XEmacs bug of long standing. 252 ;; XEmacs bug of long standing.
227 253
228 (with-temp-buffer 254 (with-temp-buffer
229 (insert "foo\201bar") 255 (insert "foo\201bar")