Premier commit

This commit is contained in:
2019-12-06 16:26:20 +01:00
commit a9524a4177
13 changed files with 532 additions and 0 deletions

16
util/common.go Normal file
View 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
View 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)
}
}