chore: fix tokens split tests
This commit is contained in:
parent
8a34013558
commit
afe75fd9f2
1 changed files with 5 additions and 83 deletions
|
|
@ -84,6 +84,7 @@ func TestSplit(t *testing.T) {
|
||||||
sep TokenType
|
sep TokenType
|
||||||
result [][]*Token
|
result [][]*Token
|
||||||
}{
|
}{
|
||||||
|
|
||||||
{
|
{
|
||||||
tokens: []*Token{
|
tokens: []*Token{
|
||||||
{
|
{
|
||||||
|
|
@ -109,6 +110,7 @@ func TestSplit(t *testing.T) {
|
||||||
},
|
},
|
||||||
sep: Asterisk,
|
sep: Asterisk,
|
||||||
result: [][]*Token{
|
result: [][]*Token{
|
||||||
|
{},
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
Type: Text,
|
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 {
|
for _, test := range tests {
|
||||||
result := Split(test.tokens, test.sep)
|
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))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue