test(go): 添加 errors.AsType、net 及手机号正则匹配测试

This commit is contained in:
张育新
2026-08-08 18:20:19 +08:00
parent f175b3a66d
commit 817344fc66
3 changed files with 65 additions and 0 deletions
+13
View File
@@ -19,3 +19,16 @@ func TestChineseRegExp(t *testing.T) {
t.Errorf("Expected [世, 界], got %v", matchStrSlice)
}
}
func TestChinaMobile(t *testing.T) {
reg, err := regexp.Compile(`^1(3\d|4[5-9]|5[0-35-9]|6[2567]|7[0-8]|8\d|9[0-35-9])\d{8}$`)
if err != nil {
t.Errorf("Failed to compile regex: %v", err)
}
// matchStrSlice := reg.FindAllString("123-12345678 1234-12345678", -1)
// if len(matchStrSlice) != 2 {
// t.Errorf("Expected 2 matches, got %d", len(matchStrSlice))
// }
matchStrSlice := reg.FindAllString("17623862704", -1)
t.Log(matchStrSlice[0])
}