|
|
@ -204,14 +204,32 @@ func TestFindAllIssueReferences(t *testing.T) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func TestRegExp_mentionPattern(t *testing.T) {
|
|
|
|
func TestRegExp_mentionPattern(t *testing.T) {
|
|
|
|
trueTestCases := []string{
|
|
|
|
trueTestCases := []struct {
|
|
|
|
"@Unknwon",
|
|
|
|
pat string
|
|
|
|
"@ANT_123",
|
|
|
|
exp string
|
|
|
|
"@xxx-DiN0-z-A..uru..s-xxx",
|
|
|
|
}{
|
|
|
|
" @lol ",
|
|
|
|
{"@Unknwon", "@Unknwon"},
|
|
|
|
" @Te-st",
|
|
|
|
{"@ANT_123", "@ANT_123"},
|
|
|
|
"(@gitea)",
|
|
|
|
{"@xxx-DiN0-z-A..uru..s-xxx", "@xxx-DiN0-z-A..uru..s-xxx"},
|
|
|
|
"[@gitea]",
|
|
|
|
{" @lol ", "@lol"},
|
|
|
|
|
|
|
|
{" @Te-st", "@Te-st"},
|
|
|
|
|
|
|
|
{"(@gitea)", "@gitea"},
|
|
|
|
|
|
|
|
{"[@gitea]", "@gitea"},
|
|
|
|
|
|
|
|
{"@gitea! this", "@gitea"},
|
|
|
|
|
|
|
|
{"@gitea? this", "@gitea"},
|
|
|
|
|
|
|
|
{"@gitea. this", "@gitea"},
|
|
|
|
|
|
|
|
{"@gitea, this", "@gitea"},
|
|
|
|
|
|
|
|
{"@gitea; this", "@gitea"},
|
|
|
|
|
|
|
|
{"@gitea!\nthis", "@gitea"},
|
|
|
|
|
|
|
|
{"\n@gitea?\nthis", "@gitea"},
|
|
|
|
|
|
|
|
{"\t@gitea.\nthis", "@gitea"},
|
|
|
|
|
|
|
|
{"@gitea,\nthis", "@gitea"},
|
|
|
|
|
|
|
|
{"@gitea;\nthis", "@gitea"},
|
|
|
|
|
|
|
|
{"@gitea!", "@gitea"},
|
|
|
|
|
|
|
|
{"@gitea?", "@gitea"},
|
|
|
|
|
|
|
|
{"@gitea.", "@gitea"},
|
|
|
|
|
|
|
|
{"@gitea,", "@gitea"},
|
|
|
|
|
|
|
|
{"@gitea;", "@gitea"},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
falseTestCases := []string{
|
|
|
|
falseTestCases := []string{
|
|
|
|
"@ 0",
|
|
|
|
"@ 0",
|
|
|
@ -219,17 +237,24 @@ func TestRegExp_mentionPattern(t *testing.T) {
|
|
|
|
"@",
|
|
|
|
"@",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"ABC",
|
|
|
|
"ABC",
|
|
|
|
|
|
|
|
"@.ABC",
|
|
|
|
"/home/gitea/@gitea",
|
|
|
|
"/home/gitea/@gitea",
|
|
|
|
"\"@gitea\"",
|
|
|
|
"\"@gitea\"",
|
|
|
|
|
|
|
|
"@@gitea",
|
|
|
|
|
|
|
|
"@gitea!this",
|
|
|
|
|
|
|
|
"@gitea?this",
|
|
|
|
|
|
|
|
"@gitea,this",
|
|
|
|
|
|
|
|
"@gitea;this",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for _, testCase := range trueTestCases {
|
|
|
|
for _, testCase := range trueTestCases {
|
|
|
|
res := mentionPattern.MatchString(testCase)
|
|
|
|
found := mentionPattern.FindStringSubmatch(testCase.pat)
|
|
|
|
assert.True(t, res)
|
|
|
|
assert.Len(t, found, 2)
|
|
|
|
|
|
|
|
assert.Equal(t, testCase.exp, found[1])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for _, testCase := range falseTestCases {
|
|
|
|
for _, testCase := range falseTestCases {
|
|
|
|
res := mentionPattern.MatchString(testCase)
|
|
|
|
res := mentionPattern.MatchString(testCase)
|
|
|
|
assert.False(t, res)
|
|
|
|
assert.False(t, res, "[%s] should be false", testCase)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|