|
|
|
@ -209,16 +209,34 @@ var testCases = []tc{
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func Test_ObsidianWikilinks_LinksStartOfInput(t *testing.T) {
|
|
|
|
|
for _, tc := range testCases {
|
|
|
|
|
mut, test := mutateTestCase(
|
|
|
|
|
tc,
|
|
|
|
|
"",
|
|
|
|
|
" test data please ignore",
|
|
|
|
|
|
|
|
|
|
[]wikilink.Lexeme{
|
|
|
|
|
{Typ: wikilink.LexText, Val: ""},
|
|
|
|
|
},
|
|
|
|
|
[]wikilink.Lexeme{
|
|
|
|
|
{Typ: wikilink.LexText, Val: " test data please ignore"},
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
t.Run(mut.name, test)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func Test_ObsidianWikilinks_LinksEndOfInput(t *testing.T) {
|
|
|
|
|
for _, tc := range testCases {
|
|
|
|
|
mut, test := mutateTestCase(tc,
|
|
|
|
|
mut, test := mutateTestCase(
|
|
|
|
|
tc,
|
|
|
|
|
"this is a ",
|
|
|
|
|
"",
|
|
|
|
|
[]wikilink.Lexeme{
|
|
|
|
|
{Typ: wikilink.LexText, Val: "this is a "},
|
|
|
|
|
},
|
|
|
|
|
nil,
|
|
|
|
|
"",
|
|
|
|
|
)
|
|
|
|
|
t.Run(mut.name, test)
|
|
|
|
|
}
|
|
|
|
@ -228,7 +246,15 @@ func Test_ObsidianWikilinks_Basic(t *testing.T) {
|
|
|
|
|
// t.Parallel()
|
|
|
|
|
|
|
|
|
|
for _, tc := range testCases {
|
|
|
|
|
mut, test := mutateTestCase(tc, "", "", nil, nil, "")
|
|
|
|
|
mut, test := mutateTestCase(
|
|
|
|
|
tc,
|
|
|
|
|
"",
|
|
|
|
|
"",
|
|
|
|
|
[]wikilink.Lexeme{
|
|
|
|
|
{Typ: wikilink.LexText, Val: ""},
|
|
|
|
|
},
|
|
|
|
|
nil,
|
|
|
|
|
)
|
|
|
|
|
t.Run(mut.name, test)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -239,8 +265,7 @@ type tc struct {
|
|
|
|
|
expected []wikilink.Lexeme
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func mutateTestCase(tc tc, prefix, suffix string, expectedPrefix, expectedSuffix []wikilink.Lexeme, name string) (tc, func(t *testing.T)) {
|
|
|
|
|
tc.name = tc.name + "/" + name
|
|
|
|
|
func mutateTestCase(tc tc, prefix, suffix string, expectedPrefix, expectedSuffix []wikilink.Lexeme) (tc, func(t *testing.T)) {
|
|
|
|
|
tc.in = prefix + tc.in
|
|
|
|
|
tc.in = tc.in + suffix
|
|
|
|
|
if expectedPrefix != nil {
|
|
|
|
@ -256,6 +281,7 @@ func mutateTestCase(tc tc, prefix, suffix string, expectedPrefix, expectedSuffix
|
|
|
|
|
defer l.L.Sync()
|
|
|
|
|
if len(tc.expected) != len(l.Items) {
|
|
|
|
|
t.Logf("expected %d tokens, got %d\n", len(tc.expected), len(l.Items))
|
|
|
|
|
t.Logf("expected items: %#v\n", tc.expected)
|
|
|
|
|
t.Logf("raw items: %#v\n", l.Items)
|
|
|
|
|
t.Fail()
|
|
|
|
|
|
|
|
|
|