upgrading test suite

dev
Nick Dumas 2 years ago
parent 4735f0b36d
commit d377070fe1

@ -16,26 +16,67 @@ func Test_Lexer(t *testing.T) {
{
name: "wikilink", in: "[[wikilink]]", expected: []wikilink.Item{
{Typ: wikilink.ItemOpenLink, Val: "[["},
{Typ: wikilink.ItemText, Val: "wikilink"},
{Typ: wikilink.ItemIdent, Val: "wikilink"},
{Typ: wikilink.ItemCloseLink, Val: "]]"},
},
},
{
name: "wikilink|display name", in: "[[wikilink|display name]]", expected: []wikilink.Item{
{Typ: wikilink.ItemOpenLink, Val: "[["},
{Typ: wikilink.ItemText, Val: "wikilink"},
{Typ: wikilink.ItemIdent, Val: "wikilink"},
{Typ: wikilink.ItemAlias, Val: "|"},
{Typ: wikilink.ItemText, Val: "display name"},
{Typ: wikilink.ItemIdent, Val: "display name"},
{Typ: wikilink.ItemCloseLink, Val: "]]"},
},
},
{
name: "wikilink|display name|second pipe", in: "[[wikilink|display name|second pipe]]", expected: []wikilink.Item{
{Typ: wikilink.ItemOpenLink, Val: "[["},
{Typ: wikilink.ItemIdent, Val: "wikilink"},
{Typ: wikilink.ItemAlias, Val: "|"},
{Typ: wikilink.ItemIdent, Val: "display name"},
{Typ: wikilink.ItemAlias, Val: "|"},
{Typ: wikilink.ItemIdent, Val: "second pipe"},
{Typ: wikilink.ItemCloseLink, Val: "]]"},
},
},
{
name: "wikilink with numeric alias|420|second pipe", in: "[[wikilink|420|second pipe]]", expected: []wikilink.Item{
{Typ: wikilink.ItemOpenLink, Val: "[["},
{Typ: wikilink.ItemIdent, Val: "wikilink"},
{Typ: wikilink.ItemAlias, Val: "|"},
{Typ: wikilink.ItemIdent, Val: "420"},
{Typ: wikilink.ItemAlias, Val: "|"},
{Typ: wikilink.ItemIdent, Val: "second pipe"},
{Typ: wikilink.ItemCloseLink, Val: "]]"},
},
},
{
name: "wikilink with spaces in filename", in: "[[wikilink spaces]]", expected: []wikilink.Item{
{Typ: wikilink.ItemOpenLink, Val: "[["},
{Typ: wikilink.ItemIdent, Val: "wikilink spaces"},
{Typ: wikilink.ItemCloseLink, Val: "]]"},
},
},
{
name: "#heading", in: "[[#heading]]", expected: []wikilink.Item{
{Typ: wikilink.ItemOpenLink, Val: "[["},
{Typ: wikilink.ItemHeading, Val: "#"},
{Typ: wikilink.ItemIdent, Val: "heading"},
{Typ: wikilink.ItemCloseLink, Val: "]]"},
},
},
{
name: "wikilink#heading", in: "[[wikilink#heading]]", expected: []wikilink.Item{
{Typ: wikilink.ItemOpenLink, Val: "[["},
{Typ: wikilink.ItemIdent, Val: "wikilink"},
{Typ: wikilink.ItemHeading, Val: "#"},
{Typ: wikilink.ItemIdent, Val: "heading"},
{Typ: wikilink.ItemCloseLink, Val: "]]"},
},
},
// {name: "", in: "", expected: []wikilink.ItemType{wikilink.ItemOpenLink, wikilink.ItemText, wikilink.ItemAlias, wikilink.ItemText, wikilink.ItemCloseLink}},
/*
{name: "wikilink|display name|second pipe", in: "[[wikilink|display name|second pipe]]", expected: []wikilink.ItemType{}},
{name: "wikilink with numeric alias|420|second pipe", in: "[[wikilink|420|second pipe]]", expected: []wikilink.ItemType{}},
{name: "wikilink with spaces in filename", in: "[[wikilink spaces]]", expected: []wikilink.ItemType{}},
{name: "#heading", in: "[[#heading]]", expected: []wikilink.ItemType{}},
{name: "wikilink#heading", in: "[[wikilink#heading]]", expected: []wikilink.ItemType{}},
{name: "", in: "", expected: []wikilink.ItemType{}},
{name: "wikilink#heading|display name", in: "[[wikilink#heading|display name]]", expected: []wikilink.ItemType{}},
{name: "wikilink#heading|display name|second pipe", in: "[[wikilink#heading|display name|second pipe]]", expected: []wikilink.ItemType{}},
{name: "wikilink with numeric aliases#heading|420|display name", in: "[[wikilink#heading|420|second pipe]]", expected: []wikilink.ItemType{}},
@ -55,12 +96,12 @@ func Test_Lexer(t *testing.T) {
for _, e := range tc.expected {
n := l.NextItem()
if e.Typ != n.Typ {
t.Logf("expected Type %s, received %s with raw value %q", e.String(), n, n.Val)
t.Logf("expected Type %s, received %s", e.Typ.String(), n.Typ.String())
t.Fail()
}
if e.Val != n.Val {
t.Logf("expected Value %s, received %s with raw value %q", e.String(), n, n.Val)
t.Logf("expected Value %q, received %q", e.Val, n.Val)
t.Fail()
}
}

Loading…
Cancel
Save