Add regex op to test

pull/301/head
wwwil 5 years ago
parent e64f61fa7f
commit e4f0f470ee

@ -185,6 +185,11 @@ func (t *testItem) execute(s string) *testOutput {
case "nothave":
expectedResultPattern = " '%s' not have '%s'"
result.testResult = !strings.Contains(flagVal, t.Compare.Value)
case "regex":
expectedResultPattern = " '%s' matched by '%s'"
opRe := regexp.MustCompile(t.Compare.Value)
result.testResult = opRe.MatchString(flagVal)
}
result.ExpectedResult = fmt.Sprintf(expectedResultPattern, t.Flag, t.Compare.Value)

Loading…
Cancel
Save