...

Source file src/github.com/gobuffalo/flect/pascalize_test.go

Documentation: github.com/gobuffalo/flect

     1  package flect
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/require"
     7  )
     8  
     9  func Test_Pascalize(t *testing.T) {
    10  	table := []tt{
    11  		{"", ""},
    12  		{"bob dylan", "BobDylan"},
    13  		{"ID", "ID"},
    14  		{"id", "ID"},
    15  		{"widgetID", "WidgetID"},
    16  		{"widget_ID", "WidgetID"},
    17  		{"Widget_ID", "WidgetID"},
    18  		{"Nice to see you!", "NiceToSeeYou"},
    19  		{"*hello*", "Hello"},
    20  		{"i've read a book! have you?", "IveReadABookHaveYou"},
    21  		{"This is `code` ok", "ThisIsCodeOK"},
    22  		{"id", "ID"},
    23  		{"ip_address", "IPAddress"},
    24  		{"some_url", "SomeURL"},
    25  	}
    26  
    27  	for _, tt := range table {
    28  		t.Run(tt.act, func(st *testing.T) {
    29  			r := require.New(st)
    30  			r.Equal(tt.exp, Pascalize(tt.act))
    31  			r.Equal(tt.exp, Pascalize(tt.exp))
    32  		})
    33  	}
    34  }
    35  

View as plain text