|
|
|
@ -3,6 +3,7 @@ package wikilink_test
|
|
|
|
|
import (
|
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
"go.uber.org/zap/zapcore"
|
|
|
|
|
|
|
|
|
|
"code.ndumas.com/ndumas/wikilink-parser"
|
|
|
|
@ -274,7 +275,6 @@ func Test_ObsidianWikilinks_LinksEndOfInput(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func Test_ObsidianWikilinks_Basic(t *testing.T) {
|
|
|
|
|
// t.Parallel()
|
|
|
|
|
|
|
|
|
|
for _, tc := range SingleWikilink {
|
|
|
|
|
mut, test := mutateTestCase(
|
|
|
|
@ -309,32 +309,8 @@ func mutateTestCase(tc tc, prefix, suffix string, expectedPrefix, expectedSuffix
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return tc, func(t *testing.T) {
|
|
|
|
|
// t.Parallel()
|
|
|
|
|
l := wikilink.Lex("testLexer", tc.in, zapcore.WarnLevel)
|
|
|
|
|
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()
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
for i, e := range tc.expected {
|
|
|
|
|
n := l.Items[i]
|
|
|
|
|
if e.Typ != n.Typ {
|
|
|
|
|
t.Logf("expected Type %s, received %s", e.Typ.String(), n.Typ.String())
|
|
|
|
|
t.Fail()
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if e.Val != n.Val {
|
|
|
|
|
t.Logf("expected Value %q, received %q", e.Val, n.Val)
|
|
|
|
|
t.Fail()
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
assert.Equal(t, tc.expected, l.Items, "token stream mismatch")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|