Premier commit
This commit is contained in:
16
util/common.go
Normal file
16
util/common.go
Normal file
@ -0,0 +1,16 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
// Counter symbols
|
||||
func Counter(s string) int {
|
||||
return utf8.RuneCountInString(s)
|
||||
}
|
||||
|
||||
// ToLower string
|
||||
func ToLower(s string) string {
|
||||
return strings.ToLower(s)
|
||||
}
|
27
util/common_test.go
Normal file
27
util/common_test.go
Normal file
@ -0,0 +1,27 @@
|
||||
package util_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/foxdeveloper/namecheck/util"
|
||||
)
|
||||
|
||||
func TestToLower(t *testing.T) {
|
||||
test := "UPPERCASE"
|
||||
want := "uppercase"
|
||||
got := util.ToLower(test)
|
||||
|
||||
if got != want {
|
||||
t.Errorf("util.ToLower(%s) = %s; want %s", test, got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCounter(t *testing.T) {
|
||||
test := "传/傳test"
|
||||
want := 7
|
||||
got := util.Counter(test)
|
||||
|
||||
if got != want {
|
||||
t.Errorf("util.Counter(%s) = %d; want %d", test, got, want)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user