blob: 6d721eb127dfff8c4232b96f4a4ecd73a398e0b5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
(define-module (test text-util)
:use-module (srfi srfi-64)
:use-module (srfi srfi-71)
:use-module (srfi srfi-88)
:use-module (text util))
(test-group "words/unwords"
(test-equal '("A" "list" "of" "words")
(words "A list of words"))
(test-equal "A joined string"
(unwords '("A" "joined" "string"))))
(test-group "lines/unlines"
(test-equal '("A" "list of" "words")
(lines "A\nlist of\nwords"))
(test-equal "A joined\nstring"
(unlines '("A joined" "string"))))
;;; TODO tests for "true" string length procedures
;;; Or better yet, remove them and format text properly.
(test-group "trim-to-width"
(test-equal "Extending strings"
"An extended string "
(trim-to-width "An extended string" 40))
(test-equal "Truncating strings"
"This is a…"
(trim-to-width "This is a rather long string" 10))
(test-equal "Exact width"
"Hello"
(trim-to-width "Hello" 5)))
(test-group "Add enumeration punctuation"
(test-equal '("")
(add-enumeration-punctuation '()))
(test-equal '("Single element")
(add-enumeration-punctuation '("Single element")))
(test-equal "Two elements"
'("Hello" " " "&" " " "World")
(add-enumeration-punctuation '("Hello" "World")))
(test-equal "Three elements and different end"
'("A" ", " "B" " " "and" " " "C")
(add-enumeration-punctuation '("A" "B" "C")
"and")))
'((text util))
|