@@ -204,32 +204,57 @@ func TestFindAllIssueReferences(t *testing.T) {
204204}
205205
206206func  TestRegExp_mentionPattern (t  * testing.T ) {
207- 	trueTestCases  :=  []string {
208- 		"@Unknwon" ,
209- 		"@ANT_123" ,
210- 		"@xxx-DiN0-z-A..uru..s-xxx" ,
211- 		"   @lol   " ,
212- 		" @Te-st" ,
213- 		"(@gitea)" ,
214- 		"[@gitea]" ,
207+ 	trueTestCases  :=  []struct  {
208+ 		pat  string 
209+ 		exp  string 
210+ 	}{
211+ 		{"@Unknwon" , "@Unknwon" },
212+ 		{"@ANT_123" , "@ANT_123" },
213+ 		{"@xxx-DiN0-z-A..uru..s-xxx" , "@xxx-DiN0-z-A..uru..s-xxx" },
214+ 		{"   @lol   " , "@lol" },
215+ 		{" @Te-st" , "@Te-st" },
216+ 		{"(@gitea)" , "@gitea" },
217+ 		{"[@gitea]" , "@gitea" },
218+ 		{"@gitea! this" , "@gitea" },
219+ 		{"@gitea? this" , "@gitea" },
220+ 		{"@gitea. this" , "@gitea" },
221+ 		{"@gitea, this" , "@gitea" },
222+ 		{"@gitea; this" , "@gitea" },
223+ 		{"@gitea!\n this" , "@gitea" },
224+ 		{"\n @gitea?\n this" , "@gitea" },
225+ 		{"\t @gitea.\n this" , "@gitea" },
226+ 		{"@gitea,\n this" , "@gitea" },
227+ 		{"@gitea;\n this" , "@gitea" },
228+ 		{"@gitea!" , "@gitea" },
229+ 		{"@gitea?" , "@gitea" },
230+ 		{"@gitea." , "@gitea" },
231+ 		{"@gitea," , "@gitea" },
232+ 		{"@gitea;" , "@gitea" },
215233	}
216234	falseTestCases  :=  []string {
217235		"@ 0" ,
218236		"@ " ,
219237		"@" ,
220238		"" ,
221239		"ABC" ,
240+ 		"@.ABC" ,
222241		"/home/gitea/@gitea" ,
223242		"\" @gitea\" " ,
243+ 		"@@gitea" ,
244+ 		"@gitea!this" ,
245+ 		"@gitea?this" ,
246+ 		"@gitea,this" ,
247+ 		"@gitea;this" ,
224248	}
225249
226250	for  _ , testCase  :=  range  trueTestCases  {
227- 		res  :=  mentionPattern .MatchString (testCase )
228- 		assert .True (t , res )
251+ 		found  :=  mentionPattern .FindStringSubmatch (testCase .pat )
252+ 		assert .Len (t , found , 2 )
253+ 		assert .Equal (t , testCase .exp , found [1 ])
229254	}
230255	for  _ , testCase  :=  range  falseTestCases  {
231256		res  :=  mentionPattern .MatchString (testCase )
232- 		assert .False (t , res )
257+ 		assert .False (t , res ,  "[%s] should be false" ,  testCase )
233258	}
234259}
235260
0 commit comments