1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-07 00:17:13 +00:00
kyverno/vendor/gotest.tools/assert/example_test.go

26 lines
531 B
Go

package assert_test
import (
"fmt"
"regexp"
"testing"
"gotest.tools/assert"
"gotest.tools/assert/cmp"
)
var t = &testing.T{}
func ExampleAssert_customComparison() {
regexPattern := func(value string, pattern string) cmp.Comparison {
return func() cmp.Result {
re := regexp.MustCompile(pattern)
if re.MatchString(value) {
return cmp.ResultSuccess
}
return cmp.ResultFailure(
fmt.Sprintf("%q did not match pattern %q", value, pattern))
}
}
assert.Assert(t, regexPattern("12345.34", `\d+.\d\d`))
}