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