2022-01-11 23:49:04 +00:00
|
|
|
package mock
|
|
|
|
|
2022-03-30 19:09:32 +00:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/golang/mock/gomock"
|
|
|
|
)
|
2022-01-11 23:49:04 +00:00
|
|
|
|
|
|
|
type anyOfMatcher struct {
|
|
|
|
values []interface{}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m anyOfMatcher) Matches(x interface{}) bool {
|
|
|
|
for _, v := range m.values {
|
|
|
|
if gomock.Eq(v).Matches(x) {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
func (m anyOfMatcher) String() string {
|
|
|
|
return fmt.Sprintf("is equal to any of %+v", m.values)
|
|
|
|
}
|
|
|
|
func AnyOf(xs ...interface{}) anyOfMatcher {
|
|
|
|
return anyOfMatcher{xs}
|
|
|
|
}
|