gitee.com/mirrors/goreporter@v0.0.0-20180902115603-df1b20f7c5d0/linters/spellcheck/misspell/mime_test.go (about)

     1  package misspell
     2  
     3  import (
     4  	"testing"
     5  )
     6  
     7  func TestIsBinaryFile(t *testing.T) {
     8  	cases := []struct {
     9  		path string
    10  		want bool
    11  	}{
    12  		{"foo.png", true},
    13  		{"foo.PNG", true},
    14  		{"README", false},
    15  		{"foo.txt", false},
    16  	}
    17  
    18  	for num, tt := range cases {
    19  		if isBinaryFilename(tt.path) != tt.want {
    20  			t.Errorf("Case %d: %s was not %v", num, tt.path, tt.want)
    21  		}
    22  	}
    23  }
    24  
    25  func TestIsSCMPath(t *testing.T) {
    26  	cases := []struct {
    27  		path string
    28  		want bool
    29  	}{
    30  		{"foo.png", false},
    31  		{"foo/.git/whatever", true},
    32  	}
    33  
    34  	for num, tt := range cases {
    35  		if isSCMPath(tt.path) != tt.want {
    36  			t.Errorf("Case %d: %s was not %v", num, tt.path, tt.want)
    37  		}
    38  	}
    39  }