|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define-module (test-suite test-string-utils) |
|
#:use-module (test-suite lib) |
|
#:use-module (texinfo string-utils)) |
|
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "test-beginning-expansion" |
|
(pass-if (equal? " Hello" |
|
(expand-tabs "\tHello"))) |
|
(pass-if (equal? " Hello" |
|
(expand-tabs "\t\tHello")))) |
|
|
|
(with-test-prefix "test-ending-expansion" |
|
(pass-if (equal? "Hello " |
|
(expand-tabs "Hello\t"))) |
|
(pass-if (equal? "Hello " |
|
(expand-tabs "Hello\t\t")))) |
|
|
|
(with-test-prefix "test-middle-expansion" |
|
(pass-if (equal? "Hello there" (expand-tabs "Hello\tthere"))) |
|
(pass-if (equal? "Hello there" (expand-tabs "Hello\t\tthere")))) |
|
|
|
(with-test-prefix "test-alternate-tab-size" |
|
(pass-if (equal? "Hello there" |
|
(expand-tabs "Hello\tthere" 3))) |
|
(pass-if (equal? "Hello there" |
|
(expand-tabs "Hello\tthere" 4))) |
|
(pass-if (equal? "Hello there" |
|
(expand-tabs "Hello\tthere" 5)))) |
|
|
|
|
|
|
|
|
|
(with-test-prefix "test-single-escape-char" |
|
(pass-if (equal? "HeElElo" |
|
(escape-special-chars "Hello" #\l #\E)))) |
|
|
|
(with-test-prefix "test-multiple-escape-chars" |
|
(pass-if (equal? "HEeElElo" |
|
(escape-special-chars "Hello" "el" #\E)))) |
|
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "collapse-repeated-chars" |
|
(define test-string |
|
"H e l l o t h e r e") |
|
|
|
(with-test-prefix "test-basic-collapse" |
|
(pass-if (equal? "H e l l o t h e r e" |
|
(collapse-repeated-chars test-string)))) |
|
|
|
(with-test-prefix "test-choose-other-char" |
|
(pass-if (equal? "H-e-l-l-o-t-h-e-r-e" |
|
(collapse-repeated-chars (transform-string test-string #\space #\-) |
|
#\-)))) |
|
|
|
(with-test-prefix "test-choose-maximum-repeats" |
|
(pass-if (equal? "H e l l o t h e r e" |
|
(collapse-repeated-chars test-string #\space 2))) |
|
(pass-if (equal? "H e l l o t h e r e" |
|
(collapse-repeated-chars test-string #\space 3))))) |
|
|
|
|
|
|
|
|
|
(with-test-prefix "text wrapping" |
|
(define test-string " |
|
The last language environment specified with |
|
`set-language-environment'. This variable should be |
|
set only with M-x customize, which is equivalent |
|
to using the function `set-language-environment'. |
|
") |
|
|
|
(with-test-prefix "runs-without-exception" |
|
(pass-if (->bool (fill-string test-string))) |
|
(pass-if (->bool (fill-string test-string #:line-width 20))) |
|
(pass-if (->bool (fill-string test-string #:initial-indent " * " #:tab-width 3)))) |
|
|
|
(with-test-prefix "test-fill-equivalent-to-joined-lines" |
|
(pass-if (equal? (fill-string test-string) |
|
(string-join (string->wrapped-lines test-string) "\n" 'infix)))) |
|
|
|
(with-test-prefix "test-no-collapse-ws" |
|
(pass-if (equal? (fill-string test-string #:collapse-whitespace? #f) |
|
"The last language environment specified with `set-language-environment'. This |
|
variable should be set only with M-x customize, which is equivalent to using |
|
the function `set-language-environment'."))) |
|
|
|
(with-test-prefix "two spaces after end of sentence" |
|
(pass-if-equal "This is a sentence. There should be two spaces before." |
|
(fill-string "This is a sentence. There should be two spaces before.")) |
|
|
|
(pass-if-equal "This is version 2.0..." |
|
(fill-string "This is version 2.0..."))) |
|
|
|
(with-test-prefix "test-no-word-break" |
|
(pass-if (equal? "thisisalongword |
|
blah |
|
blah" |
|
(fill-string "thisisalongword blah blah" |
|
#:line-width 8 |
|
#:break-long-words? #f))))) |
|
|