You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
1.1 KiB

package gemini_test
import (
"testing"
"git.r23s.eu/wojciech/gm2html/gemini"
"github.com/stretchr/testify/assert"
)
func TestParseLinkLine(t *testing.T) {
tests := []struct {
line string
href string
title string
}{
{"=> gemini://example.org/", "gemini://example.org/", "gemini://example.org/"},
{"gemini://example.org/ An example link", "gemini://example.org/", "An example link"},
{"gemini://example.org/foo Another example link at the same host", "gemini://example.org/foo", "Another example link at the same host"},
{"=>gemini://example.org/bar Yet another example link at the same host", "gemini://example.org/bar", "Yet another example link at the same host"},
{"=> foo/bar/baz.txt A relative link ", "foo/bar/baz.txt", "A relative link"},
{"=> gopher://example.org:70/1 A gopher link", "gopher://example.org:70/1", "A gopher link"},
}
for _, test := range tests {
l := gemini.ParseLinkLine(test.line)
assert.Equal(t, test.href, l.Href(), "Incorrect href: \"%s\"", test.line)
assert.Equal(t, test.title, l.Title(), "Incorrect title: \"%s\"", test.line)
}
}