1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
package parse
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestIsAlphaNumeric(t *testing.T) {
for _, r := range []rune{'a', '1', '_', 'A', 'Z'} {
assert.True(t, isAlphaNumeric(r))
}
for _, r := range []rune{' ', '[', ']', '!', '"'} {
assert.False(t, isAlphaNumeric(r))
}
}
func TestWordify(t *testing.T) {
for word, wordified := range map[string]string{
"int": "Int",
"*int": "Int",
"string": "String",
"*MyType": "MyType",
"*myType": "MyType",
"interface{}": "Interface",
"pack.type": "Packtype",
"*pack.type": "Packtype",
} {
assert.Equal(t, wordified, wordify(word, true))
}
}
|