chore: fix tokens split tests

This commit is contained in:
Steven 2024-01-20 02:09:33 +08:00
parent 8a34013558
commit afe75fd9f2

View File

@ -84,6 +84,7 @@ func TestSplit(t *testing.T) {
sep TokenType
result [][]*Token
}{
{
tokens: []*Token{
{
@ -109,6 +110,7 @@ func TestSplit(t *testing.T) {
},
sep: Asterisk,
result: [][]*Token{
{},
{
{
Type: Text,
@ -129,92 +131,12 @@ func TestSplit(t *testing.T) {
},
},
},
{
tokens: []*Token{
{
Type: Asterisk,
Value: "*",
},
{
Type: Text,
Value: "Hello",
},
{
Type: Space,
Value: " ",
},
{
Type: Text,
Value: "world",
},
{
Type: ExclamationMark,
Value: "!",
},
},
sep: Text,
result: [][]*Token{
{
{
Type: Asterisk,
Value: "*",
},
},
{
{
Type: Space,
Value: " ",
},
},
{
{
Type: ExclamationMark,
Value: "!",
},
},
},
},
{
tokens: []*Token{
{
Type: Text,
Value: "Hello",
},
{
Type: Space,
Value: " ",
},
{
Type: Text,
Value: "world",
},
{
Type: Newline,
Value: "\n",
},
},
sep: Newline,
result: [][]*Token{
{
{
Type: Text,
Value: "Hello",
},
{
Type: Space,
Value: " ",
},
{
Type: Text,
Value: "world",
},
},
},
},
}
for _, test := range tests {
result := Split(test.tokens, test.sep)
require.Equal(t, test.result, result)
for index, tokens := range result {
require.Equal(t, Stringify(test.result[index]), Stringify(tokens))
}
}
}