...

Source file src/github.com/gobuffalo/flect/name/interface_test.go

Documentation: github.com/gobuffalo/flect/name

     1  package name
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  
     7  	"github.com/stretchr/testify/require"
     8  )
     9  
    10  type car struct{}
    11  
    12  func Test_Interface(t *testing.T) {
    13  	table := []struct {
    14  		in  interface{}
    15  		out string
    16  		err bool
    17  	}{
    18  		{"foo", "foo", false},
    19  		{car{}, "car", false},
    20  		{&car{}, "car", false},
    21  		{[]car{}, "cars", false},
    22  		{false, "bool", false},
    23  	}
    24  
    25  	for _, tt := range table {
    26  		t.Run(fmt.Sprint(tt.in), func(st *testing.T) {
    27  			r := require.New(st)
    28  			n, err := Interface(tt.in)
    29  			if tt.err {
    30  				r.Error(err)
    31  				return
    32  			}
    33  			r.NoError(err)
    34  			r.Equal(tt.out, n.String())
    35  		})
    36  	}
    37  }
    38  

View as plain text