-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathwrap_test.go
More file actions
38 lines (29 loc) · 882 Bytes
/
wrap_test.go
File metadata and controls
38 lines (29 loc) · 882 Bytes
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
package textplain_test
import (
"strings"
"testing"
"github.com/mailproto/textplain"
"github.com/stretchr/testify/assert"
)
func TestWrappingInvalidLength(t *testing.T) {
body := `.stylesheet {
color: white;
background-image: url('data:image/png;base64,123456789012345678901234567890');
font-weight: bold;
margin: 0px;
}`
wrapped := textplain.WordWrap(body, -1)
assert.Equal(t, body, wrapped)
}
func TestWrappingTrailingWhitespace(t *testing.T) {
body := "1 23 45\n67\n1234567890 1 "
wrapped := textplain.WordWrap(body, 13)
assert.Equal(t, "1 23 45\n67\n1234567890 1 \n", wrapped)
wrapped = textplain.WordWrap("1234567890"+strings.Repeat(" ", 20), 10)
assert.Equal(t, "1234567890\n", wrapped)
}
func TestWrappingShorterThanLimit(t *testing.T) {
body := "1 12 12 1"
wrapped := textplain.WordWrap(body, 3)
assert.Equal(t, "1\n12\n12\n1", wrapped)
}