assert: allow comparing time.Time · stretchr/testify@087b655
@@ -6,6 +6,7 @@ import (
66"reflect"
77"runtime"
88"testing"
9+"time"
910)
10111112func TestCompare(t *testing.T) {
@@ -22,6 +23,7 @@ func TestCompare(t *testing.T) {
2223type customFloat32 float32
2324type customFloat64 float64
2425type customString string
26+type customTime time.Time
2527for _, currCase := range []struct {
2628less interface{}
2729greater interface{}
@@ -52,14 +54,17 @@ func TestCompare(t *testing.T) {
5254 {less: customFloat32(1.23), greater: customFloat32(2.23), cType: "float32"},
5355 {less: float64(1.23), greater: float64(2.34), cType: "float64"},
5456 {less: customFloat64(1.23), greater: customFloat64(2.34), cType: "float64"},
57+ {less: time.Now(), greater: time.Now().Add(time.Hour), cType: "time.Time"},
58+ {less: customTime(time.Now()), greater: customTime(time.Now().Add(time.Hour)), cType: "time.Time"},
5559 } {
5660resLess, isComparable := compare(currCase.less, currCase.greater, reflect.ValueOf(currCase.less).Kind())
5761if !isComparable {
5862t.Error("object should be comparable for type " + currCase.cType)
5963 }
60646165if resLess != compareLess {
62-t.Errorf("object less should be less than greater for type " + currCase.cType)
66+t.Errorf("object less (%v) should be less than greater (%v) for type "+currCase.cType,
67+currCase.less, currCase.greater)
6368 }
64696570resGreater, isComparable := compare(currCase.greater, currCase.less, reflect.ValueOf(currCase.less).Kind())