提交 524691b3 编写于 作者: aaronchen2k2k's avatar aaronchen2k2k

fix a bug occurred when use regx with [...], which will let expects looks like a [group]

上级 3f7c71c7
......@@ -2,19 +2,18 @@
<?php
/**
[case]
title=check string matches pattern
cid=0
pid=0
[group]
1. exactly match >> hello
2. regular expression match >> 1\d{10}
3. format string match >> %s%d
1. exactly match >> hello
2. regular expression match >> 1\d{10}
3. format string match >> %s%d
[esac]
*/
print(">> hello\n");
print(">> 13905120512\n");
print(">> abc123\n");
print(">> abc123\n");
\ No newline at end of file
......@@ -2,19 +2,18 @@
<?php
/**
[case]
title=extract content from webpage
cid=0
pid=0
[group]
1. Load web page from url http://xxx
2. Retrieve img element zt-logo.png in html
3. Check img exist >> .*zt-logo.png
1. Load web page from url http://xxx
2. Retrieve img element zt-logo.png in html
3. Check img exist >> .*zt-logo.png
[esac]
*/
$resp = file_get_contents('http://pms.zentao.net/user-login.html');
preg_match_all("/<img src='(.*)' .*>/U", $resp, $matches);
echo ">> " . $matches[1][0] . "\n";
echo ">> " . $matches[1][0] . "\n";
\ No newline at end of file
......@@ -2,19 +2,18 @@
<?php
/**
[case]
title=check remote interface response
cid=0
pid=0
[group]
1. Send a request to interface http://xxx
2. Retrieve sessionID field from response json
3. Check its format >> ^[a-z0-9]{26}
1. Send a request to interface http://xxx
2. Retrieve sessionID field from response json
3. Check its format >> ^[a-z0-9]{26}
[esac]
*/
$resp = file_get_contents('http://pms.zentao.net/?mode=getconfig');
$json = json_decode($resp);
echo ">> " . $json->sessionID . "\n";
echo ">> " . $json->sessionID . "\n";
\ No newline at end of file
......@@ -201,12 +201,12 @@ func isExpectsIdent(str string) bool {
}
func hasBrackets(str string) bool {
pass, _ := regexp.MatchString(`(?i)\[.*\]`, str)
pass, _ := regexp.MatchString(`(?i)()\[.*\]`, str)
return pass
}
func isGroup(str string) bool {
ret := hasBrackets(str) && !isStepsIdent(str) && !isExpectsIdent(str)
ret := strings.Index(str, ">>") < 0 && hasBrackets(str) && !isStepsIdent(str) && !isExpectsIdent(str)
return ret
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册