github.com/daixiang0/gci@v0.13.0/pkg/specificity/specificity_test.go (about)

     1  package specificity
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  
     7  	"github.com/stretchr/testify/assert"
     8  )
     9  
    10  func TestSpecificityOrder(t *testing.T) {
    11  	testCases := testCasesInSpecificityOrder()
    12  	for i := 1; i < len(testCases); i++ {
    13  		t.Run(fmt.Sprintf("Specificity(%v)>Specificity(%v)", testCases[i], testCases[i-1]), func(t *testing.T) {
    14  			assert.True(t, testCases[i].IsMoreSpecific(testCases[i-1]))
    15  		})
    16  	}
    17  }
    18  
    19  func TestSpecificityEquality(t *testing.T) {
    20  	for _, testCase := range testCasesInSpecificityOrder() {
    21  		t.Run(fmt.Sprintf("Specificity(%v)==Specificity(%v)", testCase, testCase), func(t *testing.T) {
    22  			assert.True(t, testCase.Equal(testCase))
    23  		})
    24  	}
    25  }
    26  
    27  func testCasesInSpecificityOrder() []MatchSpecificity {
    28  	return []MatchSpecificity{MisMatch{}, Default{}, StandardMatch{}, Match{0}, Match{1}}
    29  }