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

     1  package misspell
     2  
     3  import (
     4  	"reflect"
     5  	"testing"
     6  )
     7  
     8  func TestCaseStyle(t *testing.T) {
     9  	cases := []struct {
    10  		word string
    11  		want WordCase
    12  	}{
    13  		{"lower", AllLower},
    14  		{"what's", AllLower},
    15  		{"UPPER", AllUpper},
    16  		{"Title", Title},
    17  		{"CamelCase", Mixed},
    18  		{"camelCase", Mixed},
    19  	}
    20  
    21  	for pos, tt := range cases {
    22  		got := CaseStyle(tt.word)
    23  		if tt.want != got {
    24  			t.Errorf("Case %d %q: want %v got %v", pos, tt.word, tt.want, got)
    25  		}
    26  	}
    27  }
    28  
    29  func TestCaseVariations(t *testing.T) {
    30  	cases := []struct {
    31  		word string
    32  		want []string
    33  	}{
    34  		{"that's", []string{"that's", "That's", "THAT'S"}},
    35  	}
    36  	for pos, tt := range cases {
    37  		got := CaseVariations(tt.word, CaseStyle(tt.word))
    38  		if !reflect.DeepEqual(tt.want, got) {
    39  			t.Errorf("Case %d %q: want %v got %v", pos, tt.word, tt.want, got)
    40  		}
    41  	}
    42  }