-
Notifications
You must be signed in to change notification settings - Fork 0
/
util_test.go
56 lines (46 loc) · 1.21 KB
/
util_test.go
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
51
52
53
54
55
56
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestUtil(t *testing.T) {
type test struct {
c int
lim int
start int
end int
}
ints := []int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
for _, x := range []test{
{c: 0, lim: 9, start: 0, end: 5},
{c: 1, lim: 9, start: 0, end: 5},
{c: 2, lim: 9, start: 0, end: 5},
{c: 3, lim: 9, start: 1, end: 6},
{c: 4, lim: 9, start: 2, end: 7},
{c: 5, lim: 9, start: 3, end: 8},
{c: 6, lim: 9, start: 4, end: 9},
{c: 7, lim: 9, start: 5, end: 10},
{c: 8, lim: 9, start: 5, end: 10},
{c: 9, lim: 9, start: 5, end: 10},
} {
start, end := getScrollWindow(x.c, &ints, 2)
assert.Equal(t, start, x.start)
assert.Equal(t, end, x.end)
}
for _, x := range []test{
{c: 0, lim: 9, start: 0, end: 10},
{c: 9, lim: 9, start: 0, end: 10},
} {
start, end := getScrollWindow(x.c, &ints, 15)
assert.Equal(t, start, x.start)
assert.Equal(t, end, x.end)
}
assert.Equal(t, stripHtmlTags("foo<wbr>bar"), "foobar")
assert.Equal(
t,
stripHtmlTags(`<a href="#pxxxxxxx" class="quotelink">>>xxxxxxx</a><br>foo`),
`>>xxxxxxx foo`,
)
// w3m -dump -T text/html <<< "foo<wbr>bar"
assert.Equal(t, renderHTML("foo<wbr>bar"), "foobar\n")
}