-
Notifications
You must be signed in to change notification settings - Fork 0
/
links_test.go
39 lines (35 loc) · 1.03 KB
/
links_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
package main
import (
"testing"
)
func TestAddLinks(t *testing.T) {
type inputAndExpected struct {
input, target string
}
toTest := []inputAndExpected{
{
"dummy text [`test`] here",
"dummy text [`test`](https://pkg.go.dev/link#test) here"},
{
"dummy text [`test`] and [`also`] here",
"dummy text [`test`](https://pkg.go.dev/link#test) and [`also`](https://pkg.go.dev/link#also) here"},
{
"dummy [`(*test).again`] here",
"dummy [`(*test).again`](https://pkg.go.dev/link#test.again) here"},
{
"dummy [`(*test).again`] and [`again`] here",
"dummy [`(*test).again`](https://pkg.go.dev/link#test.again) and [`again`](https://pkg.go.dev/link#again) here"},
{
"[`(*this).one`](shouldn't change) here [`(but).this`] will",
"[`(*this).one`](shouldn't change) here [`(but).this`](https://pkg.go.dev/link#but.this) will"},
}
for i, e := range toTest {
r := AddLinks(e.input, "link")
if r != e.target {
t.Errorf(`AddLinks failed! (%d)
input: %s
target: %s
return: %s`, i, e.input, e.target, r)
}
}
}