代码拉取完成,页面将自动刷新
package devstatscode
import (
"testing"
lib "github.com/cncf/devstatscode"
)
func TestStripUnicode(t *testing.T) {
// Test cases
var testCases = []struct {
str, expected string
}{
{str: "hello", expected: "hello"},
{str: "control:\t\n\r", expected: "control:"},
{str: "gżegżółką", expected: "gzegzoka"},
{str: "net_ease_网易有态", expected: "net_ease_"},
}
// Execute test cases
for index, test := range testCases {
expected := test.expected
got := lib.StripUnicode(test.str)
if got != expected {
t.Errorf(
"test number %d, expected %v, got %v",
index+1, expected, got,
)
}
}
}
// NormalizeName - clean DB string from ', ", -, /, ., " ", trim leading and trailing space, lowercase
// Normalize Unicode characters
func TestNormalizeName(t *testing.T) {
// Test cases
var testCases = []struct {
str, expected string
}{
{str: "hello", expected: "hello"},
{str: "control:\t\n\r", expected: "control"},
{str: "gżegżółką", expected: "gzegzoka"},
{str: "net_ease_网易有态", expected: "netease"},
{str: " see;hello-world/k8s.io, said: HE`MAN ", expected: "seehelloworldk8siosaidheman"},
{str: "Contributions (issues, PRs, git pushes)", expected: "contributionsissuesprsgitpushes"},
{str: "Exclude (ro[bot]nik)", expected: "excluderobotnik"},
{str: "comment\"sallcoted'ivoire", expected: "commentsallcotedivoire"},
{str: "Piraeus-Datastore", expected: "piraeusdatastore"},
}
// Execute test cases
for index, test := range testCases {
expected := test.expected
got := lib.NormalizeName(test.str)
if got != expected {
t.Errorf(
"test number %d, expected %v, got %v",
index+1, expected, got,
)
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。