// NotEqual succeeds if value is not equal to given Go value (e.g. map, slice,
// string, etc). Before comparison, both values are converted to canonical form.
//
// Example:
//  value := NewValue(t, "foo")
//  value.NorEqual("bar")
172576
func (v *Value) NotEqual(value interface{}) *Value {
	expected, ok := canonValue(&v.chain, value)
	if !ok {
		return v
	}
	if reflect.DeepEqual(expected, v.value) {
		v.chain.fail("\nexpected value not equal to:\n%s",
			dumpValue(expected))
	}
	return v
}
376467
func (t EnumType) Equal(u convert.Equaler) bool {
	other, ok := u.(EnumType)
	if !ok {
		return false
	}
	if !convert.CascadeEqual(t.SimpleType, other.SimpleType) {
		return false
	}
	if !convert.CascadeEqual(t.BaseType, other.BaseType) {
		return false
	}
	if !t.RewritableValues {
		if !reflect.DeepEqual(t.Values, other.Values) {
			return false
		}
	}
	if !reflect.DeepEqual(t.DefaultValue, other.DefaultValue) {
		return false
	}
	return true
}
1159114
func Equal(l, r Value) (bool, error) {

	if l == nil && r == nil {
		return true, nil
	}

	if r == nil {
		switch l.(type) {
		case NilValue:
			return true, nil
		}
		return false, nil
	}
	if _, isNil := r.(NilValue); isNil {
		switch l.(type) {
		case nil:
			return true, nil
		case NilValue:
			return true, nil
		}
		return false, nil
	}

	switch lt := l.(type) {
	case nil, NilValue:
		return false, nil
	case StringValue:
		if lt.Val() == r.ToString() {
			return true, nil
		}
		return false, nil
	case IntValue:
		rhv, _ := ValueToInt64(r)
		return lt.Val() == rhv, nil
	case NumberValue:
		rhv, _ := ValueToFloat64(r)
		return lt.Val() == rhv, nil
	case BoolValue:
		rhv, _ := ValueToBool(r)
		return lt.Val() == rhv, nil
	case TimeValue:
		rhv, _ := ValueToTime(r)
		return lt.Val() == rhv, nil
	case Slice:
		if rhv, ok := r.(Slice); ok {
			if lt.Len() != rhv.Len() {
				return false, nil
			}
			rhslice := rhv.SliceValue()
			for i, lhval := range lt.SliceValue() {
				if eq, err := Equal(lhval, rhslice[i]); !eq || err != nil {
					return false, nil
				}
			}
			return true, nil
		}
	}
	return false, fmt.Errorf("Could not evaluate equals for %v = %v", l.Value(), r.Value())
}
1269171
func (e Equalities) deepValueEqual(v1, v2 reflect.Value, visited map[visit]bool, depth int) bool {
	defer makeUsefulPanic(v1)

	if !v1.IsValid() || !v2.IsValid() {
		return v1.IsValid() == v2.IsValid()
	}
	if v1.Type() != v2.Type() {
		return false
	}
	if fv, ok := e[v1.Type()]; ok {
		return fv.Call([]reflect.Value{v1, v2})[0].Bool()
	}

	hard := func(k reflect.Kind) bool {
		switch k {
		case reflect.Array, reflect.Map, reflect.Slice, reflect.Struct:
			return true
		}
		return false
	}

	if v1.CanAddr() && v2.CanAddr() && hard(v1.Kind()) {
		addr1 := v1.UnsafeAddr()
		addr2 := v2.UnsafeAddr()
		if addr1 > addr2 {
			// Canonicalize order to reduce number of entries in visited.
			addr1, addr2 = addr2, addr1
		}

		// Short circuit if references are identical ...
		if addr1 == addr2 {
			return true
		}

		// ... or already seen
		typ := v1.Type()
		v := visit{addr1, addr2, typ}
		if visited[v] {
			return true
		}

		// Remember for later.
		visited[v] = true
	}

	switch v1.Kind() {
	case reflect.Array:
		// We don't need to check length here because length is part of
		// an array's type, which has already been filtered for.
		for i := 0; i < v1.Len(); i++ {
			if !e.deepValueEqual(v1.Index(i), v2.Index(i), visited, depth+1) {
				return false
			}
		}
		return true
	case reflect.Slice:
		if (v1.IsNil() || v1.Len() == 0) != (v2.IsNil() || v2.Len() == 0) {
			return false
		}
		if v1.IsNil() || v1.Len() == 0 {
			return true
		}
		if v1.Len() != v2.Len() {
			return false
		}
		if v1.Pointer() == v2.Pointer() {
			return true
		}
		for i := 0; i < v1.Len(); i++ {
			if !e.deepValueEqual(v1.Index(i), v2.Index(i), visited, depth+1) {
				return false
			}
		}
		return true
	case reflect.Interface:
		if v1.IsNil() || v2.IsNil() {
			return v1.IsNil() == v2.IsNil()
		}
		return e.deepValueEqual(v1.Elem(), v2.Elem(), visited, depth+1)
	case reflect.Ptr:
		return e.deepValueEqual(v1.Elem(), v2.Elem(), visited, depth+1)
	case reflect.Struct:
		for i, n := 0, v1.NumField(); i < n; i++ {
			if !e.deepValueEqual(v1.Field(i), v2.Field(i), visited, depth+1) {
				return false
			}
		}
		return true
	case reflect.Map:
		if (v1.IsNil() || v1.Len() == 0) != (v2.IsNil() || v2.Len() == 0) {
			return false
		}
		if v1.IsNil() || v1.Len() == 0 {
			return true
		}
		if v1.Len() != v2.Len() {
			return false
		}
		if v1.Pointer() == v2.Pointer() {
			return true
		}
		for _, k := range v1.MapKeys() {
			if !e.deepValueEqual(v1.MapIndex(k), v2.MapIndex(k), visited, depth+1) {
				return false
			}
		}
		return true
	case reflect.Func:
		if v1.IsNil() && v2.IsNil() {
			return true
		}
		// Can't do better than this:
		return false
	default:
		// Normal equality suffices
		if !v1.CanInterface() || !v2.CanInterface() {
			panic(unexportedTypePanic{})
		}
		return v1.Interface() == v2.Interface()
	}
}
1196795
func NewStringNotEqualsIgnoreCaseFunc(key Key, values ...string) (Function, error) {
	sset := set.CreateStringSet(values...)
	if err := validateStringEqualsIgnoreCaseValues(stringNotEqualsIgnoreCase, key, sset); err != nil {
		return nil, err
	}

	return &stringNotEqualsIgnoreCaseFunc{stringEqualsIgnoreCaseFunc{key, sset}}, nil
}
72098
func (f stringEqualsFunc) evaluate(values map[string][]string) bool {
	requestValue, ok := values[http.CanonicalHeaderKey(f.k.Name())]
	if !ok {
		requestValue = values[f.k.Name()]
	}

	fvalues := f.values.ApplyFunc(substFuncFromValues(values))
	return !fvalues.Intersection(set.CreateStringSet(requestValue...)).IsEmpty()
}
283204
func (lc Lifecycle) EqualValue(u convert.Equaler) bool {
	return lc.Equal(u)
}
794067
func equalMapValues(a, e reflect.Value) bool {
	if a.IsNil() != e.IsNil() {
		return false
	}
	if a.IsNil() && e.IsNil() {
		return true
	}
	if a.Len() != e.Len() {
		return false
	}
	for _, k := range a.MapKeys() {
		valA := a.MapIndex(k)
		valE := e.MapIndex(k)

		glog.V(10).Infof("comparing maps: %v %v %v", k, valA, valE)

		if !equalFieldValues(valA, valE) {
			glog.V(4).Infof("unequal map value: %v %v %v", k, valA, valE)
			return false
		}
	}
	return true
}
1075970
func (a *assertion) Equal(obtained, expected interface{}, msgs ...string) bool {
	if !a.IsEqual(obtained, expected) {
		return a.failer.Fail(Equal, obtained, expected, msgs...)
	}
	return true
}
1136235
func (b *Boolean) Equal(value bool) *Boolean {
	if !(b.value == value) {
		b.chain.fail("expected boolean == %v, but got %v", value, b.value)
	}
	return b
}
82491
func NewNotEqual(Variable node.Node, Expression node.Node) *NotEqual {
	return &NotEqual{
		FreeFloating: nil,
		Left:         Variable,
		Right:        Expression,
	}
}
356652
func (d *Duration) NotEqual(value time.Duration) *Duration {
	if d.value == nil {
		d.chain.fail("expected duration is set, but it is not")
		return d
	}
	if !(*d.value != value) {
		d.chain.fail("\nexpected duration not equal to:\n %s", value)
	}
	return d
}
719252
func (f stringNotEqualsIgnoreCaseFunc) evaluate(values map[string][]string) bool {
	return !f.stringEqualsIgnoreCaseFunc.evaluate(values)
}
523348
func (o *RestrictHighlightAndSnippetArraysOption) Equal(o2 *RestrictHighlightAndSnippetArraysOption) bool {
	if o2 == nil {
		return o.value == false
	}
	return o.value == o2.value
}
1040647
func Equal(x, y Value) (bool, error) {
	if x, ok := x.(String); ok {
		return x == y, nil // fast path for an important special case
	}
	return EqualDepth(x, y, maxdepth)
}
191733
func ShouldDeepEqual(actual interface{}, expected ...interface{}) string {
	res := convey.ShouldResemble(actual, expected...)
	if res == "" {
		return ""
	}

	const msg0 = "Expected: '%v'\nActual:   '%v'\n(Should deep equal)!"
	const msg1 = "Expected: '%v'\nActual:   '%v'\n(Should deep equal: %v)!"

	diff := deep.Equal(expected[0], actual)
	format := "Not match %d items: %v"
	if len(diff) == 0 {
		return fmt.Sprintf(msg0, spew.Sdump(expected[0]), spew.Sdump(actual)) + "\n" + res
	}
	if len(diff) == 1 {
		format = "Not match %d item: %v"
	}
	return fmt.Sprintf(msg1, spew.Sdump(expected[0]), spew.Sdump(actual),
		fmt.Sprintf(format, len(diff), spew.Sdump(diff)),
	)
}
799224
func StringsEqual(expected string, other string, errMsg string) error {
	if expected != other {
		if errMsg == "" {
			errMsg = fmt.Sprintf("expected %s found %s", expected, other)
		}
		return NewViolation(errMsg)
	}
	return nil
}