Update vendor/

This commit is contained in:
2018-06-25 23:27:32 +01:00
parent 4f5e3ed906
commit d25ed6c1bd
182 changed files with 31368 additions and 6047 deletions

View File

@@ -2,6 +2,7 @@ package q
import (
"errors"
"go/token"
"reflect"
)
@@ -37,3 +38,30 @@ func (r fieldMatcherDelegate) MatchValue(v *reflect.Value) (bool, error) {
}
return r.MatchField(field.Interface())
}
// NewField2FieldMatcher creates a Matcher for a given field1 and field2.
func NewField2FieldMatcher(field1, field2 string, tok token.Token) Matcher {
return field2fieldMatcherDelegate{Field1: field1, Field2: field2, Tok: tok}
}
type field2fieldMatcherDelegate struct {
Field1, Field2 string
Tok token.Token
}
func (r field2fieldMatcherDelegate) Match(i interface{}) (bool, error) {
v := reflect.Indirect(reflect.ValueOf(i))
return r.MatchValue(&v)
}
func (r field2fieldMatcherDelegate) MatchValue(v *reflect.Value) (bool, error) {
field1 := v.FieldByName(r.Field1)
if !field1.IsValid() {
return false, ErrUnknownField
}
field2 := v.FieldByName(r.Field2)
if !field2.IsValid() {
return false, ErrUnknownField
}
return compare(field1.Interface(), field2.Interface(), r.Tok), nil
}

View File

@@ -178,6 +178,11 @@ func Eq(field string, v interface{}) Matcher {
return NewFieldMatcher(field, &cmp{value: v, token: token.EQL})
}
// EqF matcher, checks if the given field is equal to the given field
func EqF(field1, field2 string) Matcher {
return NewField2FieldMatcher(field1, field2, token.EQL)
}
// StrictEq matcher, checks if the given field is deeply equal to the given value
func StrictEq(field string, v interface{}) Matcher {
return NewFieldMatcher(field, &strictEq{value: v})
@@ -188,21 +193,41 @@ func Gt(field string, v interface{}) Matcher {
return NewFieldMatcher(field, &cmp{value: v, token: token.GTR})
}
// GtF matcher, checks if the given field is greater than the given field
func GtF(field1, field2 string) Matcher {
return NewField2FieldMatcher(field1, field2, token.GTR)
}
// Gte matcher, checks if the given field is greater than or equal to the given value
func Gte(field string, v interface{}) Matcher {
return NewFieldMatcher(field, &cmp{value: v, token: token.GEQ})
}
// GteF matcher, checks if the given field is greater than or equal to the given field
func GteF(field1, field2 string) Matcher {
return NewField2FieldMatcher(field1, field2, token.GEQ)
}
// Lt matcher, checks if the given field is lesser than the given value
func Lt(field string, v interface{}) Matcher {
return NewFieldMatcher(field, &cmp{value: v, token: token.LSS})
}
// LtF matcher, checks if the given field is lesser than the given field
func LtF(field1, field2 string) Matcher {
return NewField2FieldMatcher(field1, field2, token.LSS)
}
// Lte matcher, checks if the given field is lesser than or equal to the given value
func Lte(field string, v interface{}) Matcher {
return NewFieldMatcher(field, &cmp{value: v, token: token.LEQ})
}
// LteF matcher, checks if the given field is lesser than or equal to the given field
func LteF(field1, field2 string) Matcher {
return NewField2FieldMatcher(field1, field2, token.LEQ)
}
// In matcher, checks if the given field matches one of the value of the given slice.
// v must be a slice.
func In(field string, v interface{}) Matcher {