mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
chore: fix tokens split tests
This commit is contained in:
@@ -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))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user