|
1 | 1 | (require 'cl-lib)
|
2 |
| -(require 'mule-util) |
3 | 2 |
|
4 | 3 | (defvar rg-unit/long-search-pattern "everything everywhere all at once")
|
5 | 4 |
|
@@ -62,31 +61,32 @@ Instead DO-RETURN will be returned when the function is called."
|
62 | 61 | (ert-deftest rg-unit/search-pattern-truncation-in-header ()
|
63 | 62 | "Tests `rg-header-truncate-search-pattern'."
|
64 | 63 | ;; When predicate is true.
|
65 |
| - (rg-unit/mock-truncation-predicate (:max 11 :predicate always) |
66 |
| - (should (string= |
67 |
| - (concat "everything" (truncate-string-ellipsis)) |
68 |
| - (rg-header-truncate-search-pattern rg-unit/long-search-pattern)))) |
69 |
| - |
70 |
| - (rg-unit/mock-truncation-predicate (:max 5 :predicate always) |
71 |
| - (should (string= |
72 |
| - "ever…" |
73 |
| - (rg-header-truncate-search-pattern rg-unit/long-search-pattern)))) |
74 |
| - |
75 |
| - (rg-unit/mock-truncation-predicate (:max (length rg-unit/long-search-pattern) :predicate always) |
76 |
| - (should (string= |
77 |
| - "everything everywhere all at once" |
78 |
| - (rg-header-truncate-search-pattern rg-unit/long-search-pattern)))) |
79 |
| - |
80 |
| - ;; When predicate is false. |
81 |
| - (rg-unit/mock-truncation-predicate (:max 11 :predicate ignore) |
82 |
| - (should (string= |
83 |
| - "everything everywhere all at once" |
84 |
| - (rg-header-truncate-search-pattern rg-unit/long-search-pattern)))) |
85 |
| - |
86 |
| - (rg-unit/mock-truncation-predicate (:predicate ignore) |
87 |
| - (should (string= |
88 |
| - "everything everywhere all at once" |
89 |
| - (rg-header-truncate-search-pattern rg-unit/long-search-pattern))))) |
| 64 | + (let ((ellipsis-len (length (rg-truncate-string-ellipsis)))) |
| 65 | + (rg-unit/mock-truncation-predicate (:max 11 :predicate always) |
| 66 | + (should (string= |
| 67 | + (concat (substring "everything" 0 (- 11 ellipsis-len)) (rg-truncate-string-ellipsis)) |
| 68 | + (rg-header-truncate-search-pattern rg-unit/long-search-pattern)))) |
| 69 | + |
| 70 | + (rg-unit/mock-truncation-predicate (:max 5 :predicate always) |
| 71 | + (should (string= |
| 72 | + (concat (substring "ever" 0 (- 5 ellipsis-len)) (rg-truncate-string-ellipsis)) |
| 73 | + (rg-header-truncate-search-pattern rg-unit/long-search-pattern)))) |
| 74 | + |
| 75 | + (rg-unit/mock-truncation-predicate (:max (length rg-unit/long-search-pattern) :predicate always) |
| 76 | + (should (string= |
| 77 | + "everything everywhere all at once" |
| 78 | + (rg-header-truncate-search-pattern rg-unit/long-search-pattern)))) |
| 79 | + |
| 80 | + ;; When predicate is false. |
| 81 | + (rg-unit/mock-truncation-predicate (:max 11 :predicate ignore) |
| 82 | + (should (string= |
| 83 | + "everything everywhere all at once" |
| 84 | + (rg-header-truncate-search-pattern rg-unit/long-search-pattern)))) |
| 85 | + |
| 86 | + (rg-unit/mock-truncation-predicate (:predicate ignore) |
| 87 | + (should (string= |
| 88 | + "everything everywhere all at once" |
| 89 | + (rg-header-truncate-search-pattern rg-unit/long-search-pattern)))))) |
90 | 90 |
|
91 | 91 | (ert-deftest rg-unit/search-help-for-header ()
|
92 | 92 | "Tests `rg-header-search-help'."
|
|
0 commit comments