Created
June 9, 2017 17:15
-
-
Save iMega/b8984b5dfa612af8e912e1dda197d009 to your computer and use it in GitHub Desktop.
EqualWithDuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func EqualWithDuration(t *testing.T, expected, actual interface{}, delta time.Duration) bool { | |
a := reflect.ValueOf(actual) | |
e := reflect.ValueOf(expected) | |
for i := 0; i < a.NumField(); i++ { | |
if a.Field(i).Type() == reflect.TypeOf(time.Time{}) { | |
assert.WithinDuration(t, e.Field(i).Interface().(time.Time), a.Field(i).Interface().(time.Time), delta) | |
} else { | |
assert.Equal(t, e.Field(i).Interface(), a.Field(i).Interface()) | |
} | |
} | |
return true | |
} |
Author
iMega
commented
Jun 13, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment