vendor/github.com/stretchr/testify/assert/assertions.go
changeset 260 445e01aede7e
parent 256 6d9efbef00a9
equal deleted inserted replaced
259:db4911b0c721 260:445e01aede7e
     6 	"encoding/json"
     6 	"encoding/json"
     7 	"errors"
     7 	"errors"
     8 	"fmt"
     8 	"fmt"
     9 	"math"
     9 	"math"
    10 	"os"
    10 	"os"
       
    11 	"path/filepath"
    11 	"reflect"
    12 	"reflect"
    12 	"regexp"
    13 	"regexp"
    13 	"runtime"
    14 	"runtime"
    14 	"runtime/debug"
    15 	"runtime/debug"
    15 	"strings"
    16 	"strings"
   142 		parts := strings.Split(file, "/")
   143 		parts := strings.Split(file, "/")
   143 		file = parts[len(parts)-1]
   144 		file = parts[len(parts)-1]
   144 		if len(parts) > 1 {
   145 		if len(parts) > 1 {
   145 			dir := parts[len(parts)-2]
   146 			dir := parts[len(parts)-2]
   146 			if (dir != "assert" && dir != "mock" && dir != "require") || file == "mock_test.go" {
   147 			if (dir != "assert" && dir != "mock" && dir != "require") || file == "mock_test.go" {
   147 				callers = append(callers, fmt.Sprintf("%s:%d", file, line))
   148 				path, _ := filepath.Abs(file)
       
   149 				callers = append(callers, fmt.Sprintf("%s:%d", path, line))
   148 			}
   150 			}
   149 		}
   151 		}
   150 
   152 
   151 		// Drop the package
   153 		// Drop the package
   152 		segments := strings.Split(name, ".")
   154 		segments := strings.Split(name, ".")
   561 
   563 
   562 	objValue := reflect.ValueOf(object)
   564 	objValue := reflect.ValueOf(object)
   563 
   565 
   564 	switch objValue.Kind() {
   566 	switch objValue.Kind() {
   565 	// collection types are empty when they have no element
   567 	// collection types are empty when they have no element
   566 	case reflect.Array, reflect.Chan, reflect.Map, reflect.Slice:
   568 	case reflect.Chan, reflect.Map, reflect.Slice:
   567 		return objValue.Len() == 0
   569 		return objValue.Len() == 0
   568 		// pointers are empty if nil or if the value they point to is empty
   570 	// pointers are empty if nil or if the value they point to is empty
   569 	case reflect.Ptr:
   571 	case reflect.Ptr:
   570 		if objValue.IsNil() {
   572 		if objValue.IsNil() {
   571 			return true
   573 			return true
   572 		}
   574 		}
   573 		deref := objValue.Elem().Interface()
   575 		deref := objValue.Elem().Interface()
   574 		return isEmpty(deref)
   576 		return isEmpty(deref)
   575 		// for all other types, compare against the zero value
   577 	// for all other types, compare against the zero value
       
   578 	// array types are empty when they match their zero-initialized state
   576 	default:
   579 	default:
   577 		zero := reflect.Zero(objValue.Type())
   580 		zero := reflect.Zero(objValue.Type())
   578 		return reflect.DeepEqual(object, zero.Interface())
   581 		return reflect.DeepEqual(object, zero.Interface())
   579 	}
   582 	}
   580 }
   583 }
   716 
   719 
   717 // containsElement try loop over the list check if the list includes the element.
   720 // containsElement try loop over the list check if the list includes the element.
   718 // return (false, false) if impossible.
   721 // return (false, false) if impossible.
   719 // return (true, false) if element was not found.
   722 // return (true, false) if element was not found.
   720 // return (true, true) if element was found.
   723 // return (true, true) if element was found.
   721 func includeElement(list interface{}, element interface{}) (ok, found bool) {
   724 func containsElement(list interface{}, element interface{}) (ok, found bool) {
   722 
   725 
   723 	listValue := reflect.ValueOf(list)
   726 	listValue := reflect.ValueOf(list)
   724 	listKind := reflect.TypeOf(list).Kind()
   727 	listType := reflect.TypeOf(list)
       
   728 	if listType == nil {
       
   729 		return false, false
       
   730 	}
       
   731 	listKind := listType.Kind()
   725 	defer func() {
   732 	defer func() {
   726 		if e := recover(); e != nil {
   733 		if e := recover(); e != nil {
   727 			ok = false
   734 			ok = false
   728 			found = false
   735 			found = false
   729 		}
   736 		}
   762 func Contains(t TestingT, s, contains interface{}, msgAndArgs ...interface{}) bool {
   769 func Contains(t TestingT, s, contains interface{}, msgAndArgs ...interface{}) bool {
   763 	if h, ok := t.(tHelper); ok {
   770 	if h, ok := t.(tHelper); ok {
   764 		h.Helper()
   771 		h.Helper()
   765 	}
   772 	}
   766 
   773 
   767 	ok, found := includeElement(s, contains)
   774 	ok, found := containsElement(s, contains)
   768 	if !ok {
   775 	if !ok {
   769 		return Fail(t, fmt.Sprintf("%#v could not be applied builtin len()", s), msgAndArgs...)
   776 		return Fail(t, fmt.Sprintf("%#v could not be applied builtin len()", s), msgAndArgs...)
   770 	}
   777 	}
   771 	if !found {
   778 	if !found {
   772 		return Fail(t, fmt.Sprintf("%#v does not contain %#v", s, contains), msgAndArgs...)
   779 		return Fail(t, fmt.Sprintf("%#v does not contain %#v", s, contains), msgAndArgs...)
   785 func NotContains(t TestingT, s, contains interface{}, msgAndArgs ...interface{}) bool {
   792 func NotContains(t TestingT, s, contains interface{}, msgAndArgs ...interface{}) bool {
   786 	if h, ok := t.(tHelper); ok {
   793 	if h, ok := t.(tHelper); ok {
   787 		h.Helper()
   794 		h.Helper()
   788 	}
   795 	}
   789 
   796 
   790 	ok, found := includeElement(s, contains)
   797 	ok, found := containsElement(s, contains)
   791 	if !ok {
   798 	if !ok {
   792 		return Fail(t, fmt.Sprintf("\"%s\" could not be applied builtin len()", s), msgAndArgs...)
   799 		return Fail(t, fmt.Sprintf("\"%s\" could not be applied builtin len()", s), msgAndArgs...)
   793 	}
   800 	}
   794 	if found {
   801 	if found {
   795 		return Fail(t, fmt.Sprintf("\"%s\" should not contain \"%s\"", s, contains), msgAndArgs...)
   802 		return Fail(t, fmt.Sprintf("\"%s\" should not contain \"%s\"", s, contains), msgAndArgs...)
   809 	}
   816 	}
   810 	if subset == nil {
   817 	if subset == nil {
   811 		return true // we consider nil to be equal to the nil set
   818 		return true // we consider nil to be equal to the nil set
   812 	}
   819 	}
   813 
   820 
   814 	subsetValue := reflect.ValueOf(subset)
       
   815 	defer func() {
   821 	defer func() {
   816 		if e := recover(); e != nil {
   822 		if e := recover(); e != nil {
   817 			ok = false
   823 			ok = false
   818 		}
   824 		}
   819 	}()
   825 	}()
   820 
   826 
   821 	listKind := reflect.TypeOf(list).Kind()
   827 	listKind := reflect.TypeOf(list).Kind()
   822 	subsetKind := reflect.TypeOf(subset).Kind()
   828 	subsetKind := reflect.TypeOf(subset).Kind()
   823 
   829 
   824 	if listKind != reflect.Array && listKind != reflect.Slice {
   830 	if listKind != reflect.Array && listKind != reflect.Slice && listKind != reflect.Map {
   825 		return Fail(t, fmt.Sprintf("%q has an unsupported type %s", list, listKind), msgAndArgs...)
   831 		return Fail(t, fmt.Sprintf("%q has an unsupported type %s", list, listKind), msgAndArgs...)
   826 	}
   832 	}
   827 
   833 
   828 	if subsetKind != reflect.Array && subsetKind != reflect.Slice {
   834 	if subsetKind != reflect.Array && subsetKind != reflect.Slice && listKind != reflect.Map {
   829 		return Fail(t, fmt.Sprintf("%q has an unsupported type %s", subset, subsetKind), msgAndArgs...)
   835 		return Fail(t, fmt.Sprintf("%q has an unsupported type %s", subset, subsetKind), msgAndArgs...)
       
   836 	}
       
   837 
       
   838 	subsetValue := reflect.ValueOf(subset)
       
   839 	if subsetKind == reflect.Map && listKind == reflect.Map {
       
   840 		listValue := reflect.ValueOf(list)
       
   841 		subsetKeys := subsetValue.MapKeys()
       
   842 
       
   843 		for i := 0; i < len(subsetKeys); i++ {
       
   844 			subsetKey := subsetKeys[i]
       
   845 			subsetElement := subsetValue.MapIndex(subsetKey).Interface()
       
   846 			listElement := listValue.MapIndex(subsetKey).Interface()
       
   847 
       
   848 			if !ObjectsAreEqual(subsetElement, listElement) {
       
   849 				return Fail(t, fmt.Sprintf("\"%s\" does not contain \"%s\"", list, subsetElement), msgAndArgs...)
       
   850 			}
       
   851 		}
       
   852 
       
   853 		return true
   830 	}
   854 	}
   831 
   855 
   832 	for i := 0; i < subsetValue.Len(); i++ {
   856 	for i := 0; i < subsetValue.Len(); i++ {
   833 		element := subsetValue.Index(i).Interface()
   857 		element := subsetValue.Index(i).Interface()
   834 		ok, found := includeElement(list, element)
   858 		ok, found := containsElement(list, element)
   835 		if !ok {
   859 		if !ok {
   836 			return Fail(t, fmt.Sprintf("\"%s\" could not be applied builtin len()", list), msgAndArgs...)
   860 			return Fail(t, fmt.Sprintf("\"%s\" could not be applied builtin len()", list), msgAndArgs...)
   837 		}
   861 		}
   838 		if !found {
   862 		if !found {
   839 			return Fail(t, fmt.Sprintf("\"%s\" does not contain \"%s\"", list, element), msgAndArgs...)
   863 			return Fail(t, fmt.Sprintf("\"%s\" does not contain \"%s\"", list, element), msgAndArgs...)
   850 func NotSubset(t TestingT, list, subset interface{}, msgAndArgs ...interface{}) (ok bool) {
   874 func NotSubset(t TestingT, list, subset interface{}, msgAndArgs ...interface{}) (ok bool) {
   851 	if h, ok := t.(tHelper); ok {
   875 	if h, ok := t.(tHelper); ok {
   852 		h.Helper()
   876 		h.Helper()
   853 	}
   877 	}
   854 	if subset == nil {
   878 	if subset == nil {
   855 		return Fail(t, fmt.Sprintf("nil is the empty set which is a subset of every set"), msgAndArgs...)
   879 		return Fail(t, "nil is the empty set which is a subset of every set", msgAndArgs...)
   856 	}
   880 	}
   857 
   881 
   858 	subsetValue := reflect.ValueOf(subset)
       
   859 	defer func() {
   882 	defer func() {
   860 		if e := recover(); e != nil {
   883 		if e := recover(); e != nil {
   861 			ok = false
   884 			ok = false
   862 		}
   885 		}
   863 	}()
   886 	}()
   864 
   887 
   865 	listKind := reflect.TypeOf(list).Kind()
   888 	listKind := reflect.TypeOf(list).Kind()
   866 	subsetKind := reflect.TypeOf(subset).Kind()
   889 	subsetKind := reflect.TypeOf(subset).Kind()
   867 
   890 
   868 	if listKind != reflect.Array && listKind != reflect.Slice {
   891 	if listKind != reflect.Array && listKind != reflect.Slice && listKind != reflect.Map {
   869 		return Fail(t, fmt.Sprintf("%q has an unsupported type %s", list, listKind), msgAndArgs...)
   892 		return Fail(t, fmt.Sprintf("%q has an unsupported type %s", list, listKind), msgAndArgs...)
   870 	}
   893 	}
   871 
   894 
   872 	if subsetKind != reflect.Array && subsetKind != reflect.Slice {
   895 	if subsetKind != reflect.Array && subsetKind != reflect.Slice && listKind != reflect.Map {
   873 		return Fail(t, fmt.Sprintf("%q has an unsupported type %s", subset, subsetKind), msgAndArgs...)
   896 		return Fail(t, fmt.Sprintf("%q has an unsupported type %s", subset, subsetKind), msgAndArgs...)
       
   897 	}
       
   898 
       
   899 	subsetValue := reflect.ValueOf(subset)
       
   900 	if subsetKind == reflect.Map && listKind == reflect.Map {
       
   901 		listValue := reflect.ValueOf(list)
       
   902 		subsetKeys := subsetValue.MapKeys()
       
   903 
       
   904 		for i := 0; i < len(subsetKeys); i++ {
       
   905 			subsetKey := subsetKeys[i]
       
   906 			subsetElement := subsetValue.MapIndex(subsetKey).Interface()
       
   907 			listElement := listValue.MapIndex(subsetKey).Interface()
       
   908 
       
   909 			if !ObjectsAreEqual(subsetElement, listElement) {
       
   910 				return true
       
   911 			}
       
   912 		}
       
   913 
       
   914 		return Fail(t, fmt.Sprintf("%q is a subset of %q", subset, list), msgAndArgs...)
   874 	}
   915 	}
   875 
   916 
   876 	for i := 0; i < subsetValue.Len(); i++ {
   917 	for i := 0; i < subsetValue.Len(); i++ {
   877 		element := subsetValue.Index(i).Interface()
   918 		element := subsetValue.Index(i).Interface()
   878 		ok, found := includeElement(list, element)
   919 		ok, found := containsElement(list, element)
   879 		if !ok {
   920 		if !ok {
   880 			return Fail(t, fmt.Sprintf("\"%s\" could not be applied builtin len()", list), msgAndArgs...)
   921 			return Fail(t, fmt.Sprintf("\"%s\" could not be applied builtin len()", list), msgAndArgs...)
   881 		}
   922 		}
   882 		if !found {
   923 		if !found {
   883 			return true
   924 			return true
   998 // PanicTestFunc defines a func that should be passed to the assert.Panics and assert.NotPanics
  1039 // PanicTestFunc defines a func that should be passed to the assert.Panics and assert.NotPanics
   999 // methods, and represents a simple func that takes no arguments, and returns nothing.
  1040 // methods, and represents a simple func that takes no arguments, and returns nothing.
  1000 type PanicTestFunc func()
  1041 type PanicTestFunc func()
  1001 
  1042 
  1002 // didPanic returns true if the function passed to it panics. Otherwise, it returns false.
  1043 // didPanic returns true if the function passed to it panics. Otherwise, it returns false.
  1003 func didPanic(f PanicTestFunc) (bool, interface{}, string) {
  1044 func didPanic(f PanicTestFunc) (didPanic bool, message interface{}, stack string) {
  1004 
  1045 	didPanic = true
  1005 	didPanic := false
  1046 
  1006 	var message interface{}
  1047 	defer func() {
  1007 	var stack string
  1048 		message = recover()
  1008 	func() {
  1049 		if didPanic {
  1009 
  1050 			stack = string(debug.Stack())
  1010 		defer func() {
  1051 		}
  1011 			if message = recover(); message != nil {
       
  1012 				didPanic = true
       
  1013 				stack = string(debug.Stack())
       
  1014 			}
       
  1015 		}()
       
  1016 
       
  1017 		// call the target function
       
  1018 		f()
       
  1019 
       
  1020 	}()
  1052 	}()
  1021 
  1053 
  1022 	return didPanic, message, stack
  1054 	// call the target function
  1023 
  1055 	f()
       
  1056 	didPanic = false
       
  1057 
       
  1058 	return
  1024 }
  1059 }
  1025 
  1060 
  1026 // Panics asserts that the code inside the specified PanicTestFunc panics.
  1061 // Panics asserts that the code inside the specified PanicTestFunc panics.
  1027 //
  1062 //
  1028 //   assert.Panics(t, func(){ GoCrazy() })
  1063 //   assert.Panics(t, func(){ GoCrazy() })
  1104 	}
  1139 	}
  1105 
  1140 
  1106 	dt := expected.Sub(actual)
  1141 	dt := expected.Sub(actual)
  1107 	if dt < -delta || dt > delta {
  1142 	if dt < -delta || dt > delta {
  1108 		return Fail(t, fmt.Sprintf("Max difference between %v and %v allowed is %v, but difference was %v", expected, actual, delta, dt), msgAndArgs...)
  1143 		return Fail(t, fmt.Sprintf("Max difference between %v and %v allowed is %v, but difference was %v", expected, actual, delta, dt), msgAndArgs...)
       
  1144 	}
       
  1145 
       
  1146 	return true
       
  1147 }
       
  1148 
       
  1149 // WithinRange asserts that a time is within a time range (inclusive).
       
  1150 //
       
  1151 //   assert.WithinRange(t, time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second))
       
  1152 func WithinRange(t TestingT, actual, start, end time.Time, msgAndArgs ...interface{}) bool {
       
  1153 	if h, ok := t.(tHelper); ok {
       
  1154 		h.Helper()
       
  1155 	}
       
  1156 
       
  1157 	if end.Before(start) {
       
  1158 		return Fail(t, "Start should be before end", msgAndArgs...)
       
  1159 	}
       
  1160 
       
  1161 	if actual.Before(start) {
       
  1162 		return Fail(t, fmt.Sprintf("Time %v expected to be in time range %v to %v, but is before the range", actual, start, end), msgAndArgs...)
       
  1163 	} else if actual.After(end) {
       
  1164 		return Fail(t, fmt.Sprintf("Time %v expected to be in time range %v to %v, but is after the range", actual, start, end), msgAndArgs...)
  1109 	}
  1165 	}
  1110 
  1166 
  1111 	return true
  1167 	return true
  1112 }
  1168 }
  1113 
  1169 
  1159 
  1215 
  1160 	af, aok := toFloat(expected)
  1216 	af, aok := toFloat(expected)
  1161 	bf, bok := toFloat(actual)
  1217 	bf, bok := toFloat(actual)
  1162 
  1218 
  1163 	if !aok || !bok {
  1219 	if !aok || !bok {
  1164 		return Fail(t, fmt.Sprintf("Parameters must be numerical"), msgAndArgs...)
  1220 		return Fail(t, "Parameters must be numerical", msgAndArgs...)
       
  1221 	}
       
  1222 
       
  1223 	if math.IsNaN(af) && math.IsNaN(bf) {
       
  1224 		return true
  1165 	}
  1225 	}
  1166 
  1226 
  1167 	if math.IsNaN(af) {
  1227 	if math.IsNaN(af) {
  1168 		return Fail(t, fmt.Sprintf("Expected must not be NaN"), msgAndArgs...)
  1228 		return Fail(t, "Expected must not be NaN", msgAndArgs...)
  1169 	}
  1229 	}
  1170 
  1230 
  1171 	if math.IsNaN(bf) {
  1231 	if math.IsNaN(bf) {
  1172 		return Fail(t, fmt.Sprintf("Expected %v with delta %v, but was NaN", expected, delta), msgAndArgs...)
  1232 		return Fail(t, fmt.Sprintf("Expected %v with delta %v, but was NaN", expected, delta), msgAndArgs...)
  1173 	}
  1233 	}
  1186 		h.Helper()
  1246 		h.Helper()
  1187 	}
  1247 	}
  1188 	if expected == nil || actual == nil ||
  1248 	if expected == nil || actual == nil ||
  1189 		reflect.TypeOf(actual).Kind() != reflect.Slice ||
  1249 		reflect.TypeOf(actual).Kind() != reflect.Slice ||
  1190 		reflect.TypeOf(expected).Kind() != reflect.Slice {
  1250 		reflect.TypeOf(expected).Kind() != reflect.Slice {
  1191 		return Fail(t, fmt.Sprintf("Parameters must be slice"), msgAndArgs...)
  1251 		return Fail(t, "Parameters must be slice", msgAndArgs...)
  1192 	}
  1252 	}
  1193 
  1253 
  1194 	actualSlice := reflect.ValueOf(actual)
  1254 	actualSlice := reflect.ValueOf(actual)
  1195 	expectedSlice := reflect.ValueOf(expected)
  1255 	expectedSlice := reflect.ValueOf(expected)
  1196 
  1256 
  1248 	return true
  1308 	return true
  1249 }
  1309 }
  1250 
  1310 
  1251 func calcRelativeError(expected, actual interface{}) (float64, error) {
  1311 func calcRelativeError(expected, actual interface{}) (float64, error) {
  1252 	af, aok := toFloat(expected)
  1312 	af, aok := toFloat(expected)
  1253 	if !aok {
  1313 	bf, bok := toFloat(actual)
  1254 		return 0, fmt.Errorf("expected value %q cannot be converted to float", expected)
  1314 	if !aok || !bok {
       
  1315 		return 0, fmt.Errorf("Parameters must be numerical")
       
  1316 	}
       
  1317 	if math.IsNaN(af) && math.IsNaN(bf) {
       
  1318 		return 0, nil
  1255 	}
  1319 	}
  1256 	if math.IsNaN(af) {
  1320 	if math.IsNaN(af) {
  1257 		return 0, errors.New("expected value must not be NaN")
  1321 		return 0, errors.New("expected value must not be NaN")
  1258 	}
  1322 	}
  1259 	if af == 0 {
  1323 	if af == 0 {
  1260 		return 0, fmt.Errorf("expected value must have a value other than zero to calculate the relative error")
  1324 		return 0, fmt.Errorf("expected value must have a value other than zero to calculate the relative error")
  1261 	}
       
  1262 	bf, bok := toFloat(actual)
       
  1263 	if !bok {
       
  1264 		return 0, fmt.Errorf("actual value %q cannot be converted to float", actual)
       
  1265 	}
  1325 	}
  1266 	if math.IsNaN(bf) {
  1326 	if math.IsNaN(bf) {
  1267 		return 0, errors.New("actual value must not be NaN")
  1327 		return 0, errors.New("actual value must not be NaN")
  1268 	}
  1328 	}
  1269 
  1329 
  1296 		h.Helper()
  1356 		h.Helper()
  1297 	}
  1357 	}
  1298 	if expected == nil || actual == nil ||
  1358 	if expected == nil || actual == nil ||
  1299 		reflect.TypeOf(actual).Kind() != reflect.Slice ||
  1359 		reflect.TypeOf(actual).Kind() != reflect.Slice ||
  1300 		reflect.TypeOf(expected).Kind() != reflect.Slice {
  1360 		reflect.TypeOf(expected).Kind() != reflect.Slice {
  1301 		return Fail(t, fmt.Sprintf("Parameters must be slice"), msgAndArgs...)
  1361 		return Fail(t, "Parameters must be slice", msgAndArgs...)
  1302 	}
  1362 	}
  1303 
  1363 
  1304 	actualSlice := reflect.ValueOf(actual)
  1364 	actualSlice := reflect.ValueOf(actual)
  1305 	expectedSlice := reflect.ValueOf(expected)
  1365 	expectedSlice := reflect.ValueOf(expected)
  1306 
  1366 
  1373 			"actual  : %q", expected, actual), msgAndArgs...)
  1433 			"actual  : %q", expected, actual), msgAndArgs...)
  1374 	}
  1434 	}
  1375 	return true
  1435 	return true
  1376 }
  1436 }
  1377 
  1437 
       
  1438 // ErrorContains asserts that a function returned an error (i.e. not `nil`)
       
  1439 // and that the error contains the specified substring.
       
  1440 //
       
  1441 //   actualObj, err := SomeFunction()
       
  1442 //   assert.ErrorContains(t, err,  expectedErrorSubString)
       
  1443 func ErrorContains(t TestingT, theError error, contains string, msgAndArgs ...interface{}) bool {
       
  1444 	if h, ok := t.(tHelper); ok {
       
  1445 		h.Helper()
       
  1446 	}
       
  1447 	if !Error(t, theError, msgAndArgs...) {
       
  1448 		return false
       
  1449 	}
       
  1450 
       
  1451 	actual := theError.Error()
       
  1452 	if !strings.Contains(actual, contains) {
       
  1453 		return Fail(t, fmt.Sprintf("Error %#v does not contain %#v", actual, contains), msgAndArgs...)
       
  1454 	}
       
  1455 
       
  1456 	return true
       
  1457 }
       
  1458 
  1378 // matchRegexp return true if a specified regexp matches a string.
  1459 // matchRegexp return true if a specified regexp matches a string.
  1379 func matchRegexp(rx interface{}, str interface{}) bool {
  1460 func matchRegexp(rx interface{}, str interface{}) bool {
  1380 
  1461 
  1381 	var r *regexp.Regexp
  1462 	var r *regexp.Regexp
  1382 	if rr, ok := rx.(*regexp.Regexp); ok {
  1463 	if rr, ok := rx.(*regexp.Regexp); ok {
  1586 	if ek != reflect.Struct && ek != reflect.Map && ek != reflect.Slice && ek != reflect.Array && ek != reflect.String {
  1667 	if ek != reflect.Struct && ek != reflect.Map && ek != reflect.Slice && ek != reflect.Array && ek != reflect.String {
  1587 		return ""
  1668 		return ""
  1588 	}
  1669 	}
  1589 
  1670 
  1590 	var e, a string
  1671 	var e, a string
  1591 	if et != reflect.TypeOf("") {
  1672 
       
  1673 	switch et {
       
  1674 	case reflect.TypeOf(""):
       
  1675 		e = reflect.ValueOf(expected).String()
       
  1676 		a = reflect.ValueOf(actual).String()
       
  1677 	case reflect.TypeOf(time.Time{}):
       
  1678 		e = spewConfigStringerEnabled.Sdump(expected)
       
  1679 		a = spewConfigStringerEnabled.Sdump(actual)
       
  1680 	default:
  1592 		e = spewConfig.Sdump(expected)
  1681 		e = spewConfig.Sdump(expected)
  1593 		a = spewConfig.Sdump(actual)
  1682 		a = spewConfig.Sdump(actual)
  1594 	} else {
       
  1595 		e = reflect.ValueOf(expected).String()
       
  1596 		a = reflect.ValueOf(actual).String()
       
  1597 	}
  1683 	}
  1598 
  1684 
  1599 	diff, _ := difflib.GetUnifiedDiffString(difflib.UnifiedDiff{
  1685 	diff, _ := difflib.GetUnifiedDiffString(difflib.UnifiedDiff{
  1600 		A:        difflib.SplitLines(e),
  1686 		A:        difflib.SplitLines(e),
  1601 		B:        difflib.SplitLines(a),
  1687 		B:        difflib.SplitLines(a),
  1620 	Indent:                  " ",
  1706 	Indent:                  " ",
  1621 	DisablePointerAddresses: true,
  1707 	DisablePointerAddresses: true,
  1622 	DisableCapacities:       true,
  1708 	DisableCapacities:       true,
  1623 	SortKeys:                true,
  1709 	SortKeys:                true,
  1624 	DisableMethods:          true,
  1710 	DisableMethods:          true,
       
  1711 	MaxDepth:                10,
       
  1712 }
       
  1713 
       
  1714 var spewConfigStringerEnabled = spew.ConfigState{
       
  1715 	Indent:                  " ",
       
  1716 	DisablePointerAddresses: true,
       
  1717 	DisableCapacities:       true,
       
  1718 	SortKeys:                true,
  1625 	MaxDepth:                10,
  1719 	MaxDepth:                10,
  1626 }
  1720 }
  1627 
  1721 
  1628 type tHelper interface {
  1722 type tHelper interface {
  1629 	Helper()
  1723 	Helper()