Skip to content
This repository has been archived by the owner on May 2, 2020. It is now read-only.

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerb committed Apr 11, 2016
1 parent 7fb88d3 commit 6c1a467
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions is.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ func (is *Is) Strict() *Is {
// comparable (eg int32 and int64), they will be compared as though they are
// the same type.
func (is *Is) Equal(a interface{}, b interface{}) {
result := isEqual(a, b)
if !result {
if !isEqual(a, b) {
fail(is, "expected objects '%s' and '%s' to be equal, but got: %v and %v",
objectTypeName(a),
objectTypeName(b), a, b)
Expand All @@ -87,8 +86,7 @@ func (is *Is) Equal(a interface{}, b interface{}) {
// comparable (eg int32 and int64), they will be compared as though they are
// the same type.
func (is *Is) NotEqual(a interface{}, b interface{}) {
result := isEqual(a, b)
if result {
if isEqual(a, b) {
fail(is, "expected objects '%s' and '%s' not to be equal",
objectTypeName(a),
objectTypeName(b))
Expand Down Expand Up @@ -141,49 +139,43 @@ func (is *Is) NotOneOf(a interface{}, b ...interface{}) {

// Err checks the provided error object to determine if an error is present.
func (is *Is) Err(e error) {
result := isNil(e)
if result {
if isNil(e) {
fail(is, "expected error")
}
}

// NotErr checks the provided error object to determine if an error is not
// present.
func (is *Is) NotErr(e error) {
result := isNil(e)
if !result {
if !isNil(e) {
fail(is, "expected no error, but got: %v", e)
}
}

// Nil checks the provided object to determine if it is nil.
func (is *Is) Nil(o interface{}) {
result := isNil(o)
if !result {
if !isNil(o) {
fail(is, "expected object '%s' to be nil, but got: %v", objectTypeName(o), o)
}
}

// NotNil checks the provided object to determine if it is not nil.
func (is *Is) NotNil(o interface{}) {
result := isNil(o)
if result {
if isNil(o) {
fail(is, "expected object '%s' not to be nil", objectTypeName(o))
}
}

// True checks the provided boolean to determine if it is true.
func (is *Is) True(b bool) {
result := b == true
if !result {
if !b {
fail(is, "expected boolean to be true")
}
}

// False checks the provided boolean to determine if is false.
func (is *Is) False(b bool) {
result := b == false
if !result {
if b {
fail(is, "expected boolean to be false")
}
}
Expand All @@ -199,8 +191,7 @@ func (is *Is) False(b bool) {
// In cases such as slice, map, array and chan, a nil value is treated the
// same as an object with len == 0
func (is *Is) Zero(o interface{}) {
result := isZero(o)
if !result {
if !isZero(o) {
fail(is, "expected object '%s' to be zero value, but it was: %v", objectTypeName(o), o)
}
}
Expand All @@ -216,8 +207,7 @@ func (is *Is) Zero(o interface{}) {
// In cases such as slice, map, array and chan, a nil value is treated the
// same as an object with len == 0
func (is *Is) NotZero(o interface{}) {
result := isZero(o)
if result {
if isZero(o) {
fail(is, "expected object '%s' not to be zero value", objectTypeName(o))
}
}
Expand Down

0 comments on commit 6c1a467

Please sign in to comment.