diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/automated/character-fold-tests.el | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/automated/character-fold-tests.el b/test/automated/character-fold-tests.el index 40735e5df7f..4e8761e6f7b 100644 --- a/test/automated/character-fold-tests.el +++ b/test/automated/character-fold-tests.el | |||
| @@ -98,6 +98,27 @@ | |||
| 98 | ;; (character-fold--test-match-exactly "a12" "xxyy") | 98 | ;; (character-fold--test-match-exactly "a12" "xxyy") |
| 99 | )) | 99 | )) |
| 100 | 100 | ||
| 101 | (ert-deftest character-fold--speed-test () | ||
| 102 | (dolist (string (append '("tty-set-up-initial-frame-face" | ||
| 103 | "tty-set-up-initial-frame-face-frame-faceframe-faceframe-faceframe-face") | ||
| 104 | (mapcar #'character-fold--random-word '(10 50 100 | ||
| 105 | 50 100)))) | ||
| 106 | (message "Testing %s" string) | ||
| 107 | ;; Make sure we didn't just fallback on the trivial search. | ||
| 108 | (should-not (string= (regexp-quote string) | ||
| 109 | (character-fold-to-regexp string))) | ||
| 110 | (with-temp-buffer | ||
| 111 | (save-excursion (insert string)) | ||
| 112 | (let ((time (time-to-seconds (current-time)))) | ||
| 113 | ;; Our initial implementation of case-folding in char-folding | ||
| 114 | ;; created a lot of redundant paths in the regexp. Because of | ||
| 115 | ;; that, if a really long string "almost" matches, the regexp | ||
| 116 | ;; engine took a long time to realise that it doesn't match. | ||
| 117 | (should-not (character-fold-search-forward (concat string "c") nil 'noerror)) | ||
| 118 | ;; Ensure it took less than a second. | ||
| 119 | (should (< (- (time-to-seconds (current-time)) | ||
| 120 | time) | ||
| 121 | 1)))))) | ||
| 101 | 122 | ||
| 102 | (provide 'character-fold-tests) | 123 | (provide 'character-fold-tests) |
| 103 | ;;; character-fold-tests.el ends here | 124 | ;;; character-fold-tests.el ends here |