Files
bl/common/utils/go-sensitive-word-1.3.3/tool_test.go

49 lines
1.1 KiB
Go
Raw Normal View History

package go_sensitive_word
import (
"fmt"
"testing"
)
func TestEmail(t *testing.T) {
input := "我的邮箱是example@example.com你的是test@test.com。"
if HasEmail(input) {
masked := MaskEmail(input)
fmt.Println("替换后的字符串:", masked)
} else {
fmt.Println("字符串中不存在邮箱。")
}
}
func TestURL(t *testing.T) {
input := "我的网址是http://example.com你的是https://test.com。"
if HasURL(input) {
masked := MaskURL(input)
fmt.Println("替换后的字符串:", masked)
} else {
fmt.Println("字符串中不存在网址。")
}
}
func TestDigit(t *testing.T) {
input := "我的手机号码是1234567890你的是9876543210。"
if HasDigit(input, 3) {
masked := MaskDigit(input)
fmt.Println("替换后的字符串:", masked)
} else {
fmt.Println("字符串中不存在指定个数的数字。")
}
}
func TestWechat(t *testing.T) {
input := "我的是my_wechat123你的微信是your-wechat-789。"
if HasWechatID(input) {
masked := MaskWechatID(input)
fmt.Println("替换后的字符串:", masked)
} else {
fmt.Println("字符串中不存在微信号。")
}
}