mirror of
https://github.com/usememos/memos.git
synced 2025-03-15 18:20:09 +01:00
chore: fix tokens split tests
This commit is contained in:
parent
8a34013558
commit
afe75fd9f2
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user