mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-04 23:16:57 +08:00
fix #1331: use str_eq to assert string and digit equality
This commit is contained in:
@@ -45,6 +45,7 @@ var Assertions = map[string]func(t assert.TestingT, actual interface{}, expected
|
||||
"contained_by": ContainedBy,
|
||||
"str_eq": StringEqual,
|
||||
"string_equals": StringEqual,
|
||||
"equal_fold": EqualFold,
|
||||
"regex_match": RegexMatch,
|
||||
}
|
||||
|
||||
@@ -157,6 +158,12 @@ func ContainedBy(t assert.TestingT, actual, expected interface{}, msgAndArgs ...
|
||||
}
|
||||
|
||||
func StringEqual(t assert.TestingT, actual, expected interface{}, msgAndArgs ...interface{}) bool {
|
||||
a := fmt.Sprintf("%v", actual)
|
||||
e := fmt.Sprintf("%v", expected)
|
||||
return assert.True(t, a == e, msgAndArgs)
|
||||
}
|
||||
|
||||
func EqualFold(t assert.TestingT, actual, expected interface{}, msgAndArgs ...interface{}) bool {
|
||||
if !assert.IsType(t, "string", actual, msgAndArgs) {
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user