Fix generation of url regex for Go

This commit is contained in:
Kovid Goyal
2023-03-09 18:59:09 +05:30
parent 2aa9187428
commit 0e5ed29d83
7 changed files with 38 additions and 19 deletions

View File

@@ -4,10 +4,29 @@ package hints
import (
"fmt"
"kitty/tools/utils"
"testing"
"github.com/google/go-cmp/cmp"
)
var _ = fmt.Print
func TestHintMarking(t *testing.T) {
opts := &Options{Type: "url"}
r := func(text string, url ...string) {
ptext := convert_text(text, 20)
marks, _, err := find_marks(ptext, opts)
if err != nil {
t.Fatalf("%#v failed with error: %s", text, err)
}
actual := utils.Map(func(m Mark) string { return m.Text }, marks)
if diff := cmp.Diff(url, actual); diff != "" {
t.Fatalf("%#v failed:\n%s", text, diff)
}
}
u := `http://test.me/`
r(u, u)
}