Compare commits
2 Commits
975d604e2f
...
439e90357d
Author | SHA1 | Date | |
---|---|---|---|
439e90357d | |||
6c18c1c922 |
@ -69,7 +69,11 @@ func (this *Provider) funcIsEnglish(value string) bool {
|
|||||||
score := 0
|
score := 0
|
||||||
total := 0
|
total := 0
|
||||||
for _, char := range value {
|
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
|
score += 1
|
||||||
}
|
}
|
||||||
total += 1
|
total += 1
|
||||||
|
38
providers/validate/validate_test.go
Normal file
38
providers/validate/validate_test.go
Normal 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)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user