@@ -57,15 +57,20 @@ func TestDiffWithHighlightPlaceholderExhausted(t *testing.T) {
5757}
5858
5959func TestDiffWithHighlightTagMatch (t * testing.T ) {
60- totalOverflow := 0
61- for i := 0 ; i < 100 ; i ++ {
62- hcd := newHighlightCodeDiff ()
63- hcd .placeholderMaxCount = i
64- output := string (hcd .diffLineWithHighlight (DiffLineDel , `<span class="k"><</span>` , `<span class="k">></span>` ))
65- totalOverflow += hcd .placeholderOverflowCount
66- c1 := strings .Count (output , "<span" )
67- c2 := strings .Count (output , "</span" )
68- assert .Equal (t , c1 , c2 )
60+ f := func (t * testing.T , lineType DiffLineType ) {
61+ totalOverflow := 0
62+ for i := 0 ; ; i ++ {
63+ hcd := newHighlightCodeDiff ()
64+ hcd .placeholderMaxCount = i
65+ output := string (hcd .diffLineWithHighlight (lineType , `<span class="k"><</span>` , `<span class="k">></span>` ))
66+ totalOverflow += hcd .placeholderOverflowCount
67+ assert .Equal (t , strings .Count (output , "<span" ), strings .Count (output , "</span" ))
68+ if hcd .placeholderOverflowCount == 0 {
69+ break
70+ }
71+ }
72+ assert .NotZero (t , totalOverflow )
6973 }
70- assert .NotZero (t , totalOverflow )
74+ t .Run ("DiffLineAdd" , func (t * testing.T ) { f (t , DiffLineAdd ) })
75+ t .Run ("DiffLineDel" , func (t * testing.T ) { f (t , DiffLineDel ) })
7176}
0 commit comments