change: add popups

This commit is contained in:
lilong.129
2023-06-06 22:25:22 +08:00
parent f3e5f3ac85
commit a91d9c5b11
3 changed files with 28 additions and 5 deletions
+22
View File
@@ -6,6 +6,7 @@ import (
"bytes"
"fmt"
"os"
"regexp"
"testing"
)
@@ -50,3 +51,24 @@ func TestOCRWithLocalFile(t *testing.T) {
t.Fatal(err)
}
}
func matchPopup(text string) bool {
for _, popup := range popups {
if regexp.MustCompile(popup[1]).MatchString(text) {
return true
}
}
return false
}
func TestMatchRegex(t *testing.T) {
testData := []string{
"以后再说", "我知道了", "同意", "拒绝", "稍后",
"始终允许", "继续使用", "仅在使用中允许",
}
for _, text := range testData {
if !matchPopup(text) {
t.Fatal(text)
}
}
}