aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/smartystreets/assertions/equal_method.go
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2019-10-23 23:03:17 -0700
committerGitHub <noreply@github.com>2019-10-23 23:03:17 -0700
commit613139e7bef81d3573e7988a47eb6765f3de347a (patch)
tree49de7277898d3ff47a122c072568edb8ed4c9ac9 /vendor/github.com/smartystreets/assertions/equal_method.go
parentfb100dbf98f02e4c631d142ff0f52ec29ee2f00c (diff)
Enable Go modules (#5835)
* Remove vendor * Enable Go modules * ci: add command to fetch dependencies * ci: update setting * ci: update settings * Require Go 1.11 * Rename module name to gogs.io/gogs
Diffstat (limited to 'vendor/github.com/smartystreets/assertions/equal_method.go')
-rw-r--r--vendor/github.com/smartystreets/assertions/equal_method.go75
1 files changed, 0 insertions, 75 deletions
diff --git a/vendor/github.com/smartystreets/assertions/equal_method.go b/vendor/github.com/smartystreets/assertions/equal_method.go
deleted file mode 100644
index c4fc38fa..00000000
--- a/vendor/github.com/smartystreets/assertions/equal_method.go
+++ /dev/null
@@ -1,75 +0,0 @@
-package assertions
-
-import "reflect"
-
-type equalityMethodSpecification struct {
- a interface{}
- b interface{}
-
- aType reflect.Type
- bType reflect.Type
-
- equalMethod reflect.Value
-}
-
-func newEqualityMethodSpecification(a, b interface{}) *equalityMethodSpecification {
- return &equalityMethodSpecification{
- a: a,
- b: b,
- }
-}
-
-func (this *equalityMethodSpecification) IsSatisfied() bool {
- if !this.bothAreSameType() {
- return false
- }
- if !this.typeHasEqualMethod() {
- return false
- }
- if !this.equalMethodReceivesSameTypeForComparison() {
- return false
- }
- if !this.equalMethodReturnsBool() {
- return false
- }
- return true
-}
-
-func (this *equalityMethodSpecification) bothAreSameType() bool {
- this.aType = reflect.TypeOf(this.a)
- if this.aType == nil {
- return false
- }
- if this.aType.Kind() == reflect.Ptr {
- this.aType = this.aType.Elem()
- }
- this.bType = reflect.TypeOf(this.b)
- return this.aType == this.bType
-}
-func (this *equalityMethodSpecification) typeHasEqualMethod() bool {
- aInstance := reflect.ValueOf(this.a)
- this.equalMethod = aInstance.MethodByName("Equal")
- return this.equalMethod != reflect.Value{}
-}
-
-func (this *equalityMethodSpecification) equalMethodReceivesSameTypeForComparison() bool {
- signature := this.equalMethod.Type()
- return signature.NumIn() == 1 && signature.In(0) == this.aType
-}
-
-func (this *equalityMethodSpecification) equalMethodReturnsBool() bool {
- signature := this.equalMethod.Type()
- return signature.NumOut() == 1 && signature.Out(0) == reflect.TypeOf(true)
-}
-
-func (this *equalityMethodSpecification) AreEqual() bool {
- a := reflect.ValueOf(this.a)
- b := reflect.ValueOf(this.b)
- return areEqual(a, b) && areEqual(b, a)
-}
-func areEqual(receiver reflect.Value, argument reflect.Value) bool {
- equalMethod := receiver.MethodByName("Equal")
- argumentList := []reflect.Value{argument}
- result := equalMethod.Call(argumentList)
- return result[0].Bool()
-}