Compare commits

...

2 Commits

2 changed files with 43 additions and 1 deletions

View File

@ -69,7 +69,11 @@ func (this *Provider) funcIsEnglish(value string) bool {
score := 0
total := 0
for _, char := range value {
if char >= 'a' && char <= 'z' || char >= 'A' && char <= 'Z' || char >= '0' || char <= '9' {
ok :=
char >= 'a' && char <= 'z' ||
char >= 'A' && char <= 'Z' ||
char >= '0' && char <= '9'
if ok {
score += 1
}
total += 1

View File

@ -0,0 +1,38 @@
package validate
import "testing"
func TestFuncIsEnglish(test *testing.T) {
russian :=
"Качество изделия будет напрямую зависеть от точности " +
"соблюдения всех правил технологии выполнения " +
"https://some-random-scam-link-they-sent-me.com"
symbols :=
")(*#&$(*89347928374)(*/./,./,/,./.,) half is english but it " +
"will still be over the threshold"
english :=
"A limousine service offers luxurious, chauffeur-driven " +
"vehicles for various occasions. For Seattle residents and " +
"visitors, <a href=https://scam.com/> ScamTac airport limo " +
"service </a> is a popular choice. This service provides " +
"professional chauffeurs who ensure a smooth, comfortable " +
"ride to and from ScamTac airport. The fleet typically " +
"includes sedans, SUVs, and stretch limousines, catering to " +
"different group sizes and preferences. Key features include " +
"timely pick-ups, meet-and-greet services, and luggage " +
"assistance. Whether for business travel, special events, or " +
"simply a stress-free airport transfer, ScamTac airport limo " +
"service ensures a high-end travel experience. - " +
"https://scam.com/"
provider := new(Provider)
if got, correct := provider.funcIsEnglish(russian), false; got != correct {
test.Fatal("incorrect:", correct)
}
if got, correct := provider.funcIsEnglish(symbols), false; got != correct {
test.Fatal("incorrect:", correct)
}
if got, correct := provider.funcIsEnglish(english), true; got != correct {
test.Fatal("incorrect:", correct)
}
}