comparison tests/automated/case-tests.el @ 4855:189fb67ca31a

Create Assert-eq, Assert-equal, etc. These are equivalent to (Assert (eq ...)) but display both the actual value and the expected value of the comparison. Use them throughout the test suite.
author Ben Wing <ben@xemacs.org>
date Thu, 14 Jan 2010 02:18:03 -0600
parents 1982c8c55632
children 1fbf8bffa545
comparison
equal deleted inserted replaced
4854:95c4ced5c07c 4855:189fb67ca31a
93 "!\"#$%&'()*+,-./0123456789:;<=>?@abcdefghijklmnopqrstuvwxyz[\\]^_`ABCDEFGHIJKLMNOPQRSTUVWXYZ{|}~" 93 "!\"#$%&'()*+,-./0123456789:;<=>?@abcdefghijklmnopqrstuvwxyz[\\]^_`ABCDEFGHIJKLMNOPQRSTUVWXYZ{|}~"
94 string-127-through-160 94 string-127-through-160
95 "¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿àáâãäåæçèéêëìíîïðñòóôõö×øùúûüýþßÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ÷ØÙÚÛÜÝÞÿ")) 95 "¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿àáâãäåæçèéêëìíîïðñòóôõö×øùúûüýþßÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ÷ØÙÚÛÜÝÞÿ"))
96 (table (standard-case-table))) 96 (table (standard-case-table)))
97 (dotimes (i 256) 97 (dotimes (i 256)
98 (Assert (eq (get-case-table 'downcase (int-to-char i) table) 98 (Assert-eq (get-case-table 'downcase (int-to-char i) table)
99 (aref downcase-string i))) 99 (aref downcase-string i))
100 (Assert (eq (get-case-table 'upcase (int-to-char i) table) 100 (Assert-eq (get-case-table 'upcase (int-to-char i) table)
101 (aref upcase-string i))))) 101 (aref upcase-string i))))
102 102
103 (Check-Error-Message error "Char case must be downcase or upcase" 103 (Check-Error-Message error "Char case must be downcase or upcase"
104 (get-case-table 'foo ?a (standard-case-table))) 104 (get-case-table 'foo ?a (standard-case-table)))
105 105
106 (Assert 106 (Assert
163 163
164 (with-temp-buffer 164 (with-temp-buffer
165 (insert "Test Buffer") 165 (insert "Test Buffer")
166 (let ((case-fold-search t)) 166 (let ((case-fold-search t))
167 (goto-char (point-min)) 167 (goto-char (point-min))
168 (Assert (eq (search-forward "test buffer" nil t) 12)) 168 (Assert-eq (search-forward "test buffer" nil t) 12)
169 (goto-char (point-min)) 169 (goto-char (point-min))
170 (Assert (eq (search-forward "Test buffer" nil t) 12)) 170 (Assert-eq (search-forward "Test buffer" nil t) 12)
171 (goto-char (point-min)) 171 (goto-char (point-min))
172 (Assert (eq (search-forward "Test Buffer" nil t) 12)) 172 (Assert-eq (search-forward "Test Buffer" nil t) 12)
173 173
174 (setq case-fold-search nil) 174 (setq case-fold-search nil)
175 (goto-char (point-min)) 175 (goto-char (point-min))
176 (Assert (not (search-forward "test buffer" nil t))) 176 (Assert (not (search-forward "test buffer" nil t)))
177 (goto-char (point-min)) 177 (goto-char (point-min))
178 (Assert (not (search-forward "Test buffer" nil t))) 178 (Assert (not (search-forward "Test buffer" nil t)))
179 (goto-char (point-min)) 179 (goto-char (point-min))
180 (Assert (eq (search-forward "Test Buffer" nil t) 12)))) 180 (Assert-eq (search-forward "Test Buffer" nil t) 12)))
181 181
182 (with-temp-buffer 182 (with-temp-buffer
183 (insert "abcdefghijklmnäopqrstuÄvwxyz") 183 (insert "abcdefghijklmnäopqrstuÄvwxyz")
184 ;; case insensitive 184 ;; case insensitive
185 (Assert (not (search-forward "ö" nil t))) 185 (Assert (not (search-forward "ö" nil t)))
186 (goto-char (point-min)) 186 (goto-char (point-min))
187 (Assert (eq 16 (search-forward "ä" nil t))) 187 (Assert-eq 16 (search-forward "ä" nil t))
188 (Assert (eq 24 (search-forward "ä" nil t))) 188 (Assert-eq 24 (search-forward "ä" nil t))
189 (goto-char (point-min)) 189 (goto-char (point-min))
190 (Assert (eq 16 (search-forward "Ä" nil t))) 190 (Assert-eq 16 (search-forward "Ä" nil t))
191 (Assert (eq 24 (search-forward "Ä" nil t))) 191 (Assert-eq 24 (search-forward "Ä" nil t))
192 (goto-char (point-max)) 192 (goto-char (point-max))
193 (Assert (eq 23 (search-backward "ä" nil t))) 193 (Assert-eq 23 (search-backward "ä" nil t))
194 (Assert (eq 15 (search-backward "ä" nil t))) 194 (Assert-eq 15 (search-backward "ä" nil t))
195 (goto-char (point-max)) 195 (goto-char (point-max))
196 (Assert (eq 23 (search-backward "Ä" nil t))) 196 (Assert-eq 23 (search-backward "Ä" nil t))
197 (Assert (eq 15 (search-backward "Ä" nil t))) 197 (Assert-eq 15 (search-backward "Ä" nil t))
198 ;; case sensitive 198 ;; case sensitive
199 (setq case-fold-search nil) 199 (setq case-fold-search nil)
200 (goto-char (point-min)) 200 (goto-char (point-min))
201 (Assert (not (search-forward "ö" nil t))) 201 (Assert (not (search-forward "ö" nil t)))
202 (goto-char (point-min)) 202 (goto-char (point-min))
203 (Assert (eq 16 (search-forward "ä" nil t))) 203 (Assert-eq 16 (search-forward "ä" nil t))
204 (Assert (not (search-forward "ä" nil t))) 204 (Assert (not (search-forward "ä" nil t)))
205 (goto-char (point-min)) 205 (goto-char (point-min))
206 (Assert (eq 24 (search-forward "Ä" nil t))) 206 (Assert-eq 24 (search-forward "Ä" nil t))
207 (goto-char 16) 207 (goto-char 16)
208 (Assert (eq 24 (search-forward "Ä" nil t))) 208 (Assert-eq 24 (search-forward "Ä" nil t))
209 (goto-char (point-max)) 209 (goto-char (point-max))
210 (Assert (eq 15 (search-backward "ä" nil t))) 210 (Assert-eq 15 (search-backward "ä" nil t))
211 (goto-char 15) 211 (goto-char 15)
212 (Assert (not (search-backward "ä" nil t))) 212 (Assert (not (search-backward "ä" nil t)))
213 (goto-char (point-max)) 213 (goto-char (point-max))
214 (Assert (eq 23 (search-backward "Ä" nil t))) 214 (Assert-eq 23 (search-backward "Ä" nil t))
215 (Assert (not (search-backward "Ä" nil t)))) 215 (Assert (not (search-backward "Ä" nil t))))
216 216
217 (with-temp-buffer 217 (with-temp-buffer
218 (insert "aaaaäÄäÄäÄäÄäÄbbbb") 218 (insert "aaaaäÄäÄäÄäÄäÄbbbb")
219 (goto-char (point-min)) 219 (goto-char (point-min))
220 (Assert (eq 15 (search-forward "ää" nil t 5))) 220 (Assert-eq 15 (search-forward "ää" nil t 5))
221 (goto-char (point-min)) 221 (goto-char (point-min))
222 (Assert (not (search-forward "ää" nil t 6))) 222 (Assert (not (search-forward "ää" nil t 6)))
223 (goto-char (point-max)) 223 (goto-char (point-max))
224 (Assert (eq 5 (search-backward "ää" nil t 5))) 224 (Assert-eq 5 (search-backward "ää" nil t 5))
225 (goto-char (point-max)) 225 (goto-char (point-max))
226 (Assert (not (search-backward "ää" nil t 6)))) 226 (Assert (not (search-backward "ää" nil t 6))))
227 227
228 (when (featurep 'mule) 228 (when (featurep 'mule)
229 (let* ((hiragana-a (make-char 'japanese-jisx0208 36 34)) 229 (let* ((hiragana-a (make-char 'japanese-jisx0208 36 34))
238 (insert hiragana-a "abcdefg" a-diaeresis) 238 (insert hiragana-a "abcdefg" a-diaeresis)
239 ;; forward 239 ;; forward
240 (goto-char (point-min)) 240 (goto-char (point-min))
241 (Assert (not (search-forward "ö" nil t))) 241 (Assert (not (search-forward "ö" nil t)))
242 (goto-char (point-min)) 242 (goto-char (point-min))
243 (Assert (eq 2 (search-forward str-hiragana-a nil t))) 243 (Assert-eq 2 (search-forward str-hiragana-a nil t))
244 (goto-char (point-min)) 244 (goto-char (point-min))
245 (Assert (eq 2 (search-forward str-a-diaeresis nil t))) 245 (Assert-eq 2 (search-forward str-a-diaeresis nil t))
246 (goto-char (1+ (point-min))) 246 (goto-char (1+ (point-min)))
247 (Assert (eq (point-max) 247 (Assert-eq (point-max)
248 (search-forward str-hiragana-a nil t))) 248 (search-forward str-hiragana-a nil t))
249 (goto-char (1+ (point-min))) 249 (goto-char (1+ (point-min)))
250 (Assert (eq (point-max) 250 (Assert-eq (point-max)
251 (search-forward str-a-diaeresis nil t))) 251 (search-forward str-a-diaeresis nil t))
252 ;; backward 252 ;; backward
253 (goto-char (point-max)) 253 (goto-char (point-max))
254 (Assert (not (search-backward "ö" nil t))) 254 (Assert (not (search-backward "ö" nil t)))
255 (goto-char (point-max)) 255 (goto-char (point-max))
256 (Assert (eq (1- (point-max)) (search-backward str-hiragana-a nil t))) 256 (Assert-eq (1- (point-max)) (search-backward str-hiragana-a nil t))
257 (goto-char (point-max)) 257 (goto-char (point-max))
258 (Assert (eq (1- (point-max)) (search-backward str-a-diaeresis nil t))) 258 (Assert-eq (1- (point-max)) (search-backward str-a-diaeresis nil t))
259 (goto-char (1- (point-max))) 259 (goto-char (1- (point-max)))
260 (Assert (eq 1 (search-backward str-hiragana-a nil t))) 260 (Assert-eq 1 (search-backward str-hiragana-a nil t))
261 (goto-char (1- (point-max))) 261 (goto-char (1- (point-max)))
262 (Assert (eq 1 (search-backward str-a-diaeresis nil t))) 262 (Assert-eq 1 (search-backward str-a-diaeresis nil t))
263 (replace-match "a") 263 (replace-match "a")
264 (Assert (looking-at (format "abcdefg%c" a-diaeresis)))) 264 (Assert (looking-at (format "abcdefg%c" a-diaeresis))))
265 (with-temp-buffer 265 (with-temp-buffer
266 (set-case-table case-table) 266 (set-case-table case-table)
267 (insert string) 267 (insert string)
268 (insert string) 268 (insert string)
269 (insert string) 269 (insert string)
270 (insert string) 270 (insert string)
271 (insert string) 271 (insert string)
272 (goto-char (point-min)) 272 (goto-char (point-min))
273 (Assert (eq 11 (search-forward string nil t 5))) 273 (Assert-eq 11 (search-forward string nil t 5))
274 (goto-char (point-min)) 274 (goto-char (point-min))
275 (Assert (not (search-forward string nil t 6))) 275 (Assert (not (search-forward string nil t 6)))
276 (goto-char (point-max)) 276 (goto-char (point-max))
277 (Assert (eq 1 (search-backward string nil t 5))) 277 (Assert-eq 1 (search-backward string nil t 5))
278 (goto-char (point-max)) 278 (goto-char (point-max))
279 (Assert (not (search-backward string nil t 6)))))) 279 (Assert (not (search-backward string nil t 6))))))
280 280
281 ;; Bug reported in http://mid.gmane.org/y9lk5lu5orq.fsf@deinprogramm.de from 281 ;; Bug reported in http://mid.gmane.org/y9lk5lu5orq.fsf@deinprogramm.de from
282 ;; Michael Sperber. Fixed 2008-01-29. 282 ;; Michael Sperber. Fixed 2008-01-29.
295 ;; Boyer-Moore. 295 ;; Boyer-Moore.
296 ;; 296 ;;
297 ;; But searches for ASCII strings in buffers with nothing above ?\xFF 297 ;; But searches for ASCII strings in buffers with nothing above ?\xFF
298 ;; use Boyer Moore with the current implementation, which is the 298 ;; use Boyer Moore with the current implementation, which is the
299 ;; important thing for the Gnus use case. 299 ;; important thing for the Gnus use case.
300 (Assert (= (1+ (length target)) (search-forward target nil t))))) 300 (Assert= (1+ (length target)) (search-forward target nil t))))
301 301
302 (Skip-Test-Unless 302 (Skip-Test-Unless
303 (boundp 'debug-xemacs-searches) ; normal when we have DEBUG_XEMACS 303 (boundp 'debug-xemacs-searches) ; normal when we have DEBUG_XEMACS
304 "not a DEBUG_XEMACS build" 304 "not a DEBUG_XEMACS build"
305 "checks that the algorithm chosen by #'search-forward is relatively sane" 305 "checks that the algorithm chosen by #'search-forward is relatively sane"
311 (Assert (search-forward "Fleiss")) 311 (Assert (search-forward "Fleiss"))
312 (delete-region (point-min) (point-max)) 312 (delete-region (point-min) (point-max))
313 (insert "\n\nDer beruhmte deutsche Flei\xdf\n\n") 313 (insert "\n\nDer beruhmte deutsche Flei\xdf\n\n")
314 (goto-char (point-min)) 314 (goto-char (point-min))
315 (Assert (search-forward "Flei\xdf")) 315 (Assert (search-forward "Flei\xdf"))
316 (Assert (eq 'boyer-moore search-algorithm-used)) 316 (Assert-eq 'boyer-moore search-algorithm-used)
317 (delete-region (point-min) (point-max)) 317 (delete-region (point-min) (point-max))
318 (when (featurep 'mule) 318 (when (featurep 'mule)
319 (insert "\n\nDer beruhmte deutsche Flei\xdf\n\n") 319 (insert "\n\nDer beruhmte deutsche Flei\xdf\n\n")
320 (goto-char (point-min)) 320 (goto-char (point-min))
321 (Assert 321 (Assert
322 (search-forward (format "Fle%c\xdf" 322 (search-forward (format "Fle%c\xdf"
323 (make-char 'latin-iso8859-9 #xfd)))) 323 (make-char 'latin-iso8859-9 #xfd))))
324 (Assert (eq 'boyer-moore search-algorithm-used)) 324 (Assert-eq 'boyer-moore search-algorithm-used)
325 (insert (make-char 'latin-iso8859-9 #xfd)) 325 (insert (make-char 'latin-iso8859-9 #xfd))
326 (goto-char (point-min)) 326 (goto-char (point-min))
327 (Assert (search-forward "Flei\xdf")) 327 (Assert (search-forward "Flei\xdf"))
328 (Assert (eq 'simple-search search-algorithm-used)) 328 (Assert-eq 'simple-search search-algorithm-used)
329 (goto-char (point-min)) 329 (goto-char (point-min))
330 (Assert (search-forward (format "Fle%c\xdf" 330 (Assert (search-forward (format "Fle%c\xdf"
331 (make-char 'latin-iso8859-9 #xfd)))) 331 (make-char 'latin-iso8859-9 #xfd))))
332 (Assert (eq 'simple-search search-algorithm-used)))))) 332 (Assert-eq 'simple-search search-algorithm-used)))))
333 333