MCPcopy
hub / github.com/stretchr/testify / TestCompare

Function TestCompare

assert/assertion_compare_test.go:12–97  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestCompare(t *testing.T) {
13 t.Parallel()
14
15 type customString string
16 type customInt int
17 type customInt8 int8
18 type customInt16 int16
19 type customInt32 int32
20 type customInt64 int64
21 type customUInt uint
22 type customUInt8 uint8
23 type customUInt16 uint16
24 type customUInt32 uint32
25 type customUInt64 uint64
26 type customFloat32 float32
27 type customFloat64 float64
28 type customUintptr uintptr
29 type customTime time.Time
30 type customBytes []byte
31 for _, currCase := range []struct {
32 less interface{}
33 greater interface{}
34 cType string
35 }{
36 {less: customString("a"), greater: customString("b"), cType: "string"},
37 {less: "a", greater: "b", cType: "string"},
38 {less: customInt(1), greater: customInt(2), cType: "int"},
39 {less: int(1), greater: int(2), cType: "int"},
40 {less: customInt8(1), greater: customInt8(2), cType: "int8"},
41 {less: int8(1), greater: int8(2), cType: "int8"},
42 {less: customInt16(1), greater: customInt16(2), cType: "int16"},
43 {less: int16(1), greater: int16(2), cType: "int16"},
44 {less: customInt32(1), greater: customInt32(2), cType: "int32"},
45 {less: int32(1), greater: int32(2), cType: "int32"},
46 {less: customInt64(1), greater: customInt64(2), cType: "int64"},
47 {less: int64(1), greater: int64(2), cType: "int64"},
48 {less: customUInt(1), greater: customUInt(2), cType: "uint"},
49 {less: uint8(1), greater: uint8(2), cType: "uint8"},
50 {less: customUInt8(1), greater: customUInt8(2), cType: "uint8"},
51 {less: uint16(1), greater: uint16(2), cType: "uint16"},
52 {less: customUInt16(1), greater: customUInt16(2), cType: "uint16"},
53 {less: uint32(1), greater: uint32(2), cType: "uint32"},
54 {less: customUInt32(1), greater: customUInt32(2), cType: "uint32"},
55 {less: uint64(1), greater: uint64(2), cType: "uint64"},
56 {less: customUInt64(1), greater: customUInt64(2), cType: "uint64"},
57 {less: float32(1.23), greater: float32(2.34), cType: "float32"},
58 {less: customFloat32(1.23), greater: customFloat32(2.23), cType: "float32"},
59 {less: float64(1.23), greater: float64(2.34), cType: "float64"},
60 {less: customFloat64(1.23), greater: customFloat64(2.34), cType: "float64"},
61 {less: uintptr(1), greater: uintptr(2), cType: "uintptr"},
62 {less: customUintptr(1), greater: customUintptr(2), cType: "uint64"},
63 {less: time.Now(), greater: time.Now().Add(time.Hour), cType: "time.Time"},
64 {less: time.Date(2024, 0, 0, 0, 0, 0, 0, time.Local), greater: time.Date(2263, 0, 0, 0, 0, 0, 0, time.Local), cType: "time.Time"},
65 {less: customTime(time.Now()), greater: customTime(time.Now().Add(time.Hour)), cType: "time.Time"},
66 {less: []byte{1, 1}, greater: []byte{1, 2}, cType: "[]byte"},
67 {less: customBytes([]byte{1, 1}), greater: customBytes([]byte{1, 2}), cType: "[]byte"},
68 } {
69 resLess, isComparable := compare(currCase.less, currCase.greater, reflect.ValueOf(currCase.less).Kind())

Callers

nothing calls this directly

Calls 15

customStringTypeAlias · 0.85
customIntTypeAlias · 0.85
customInt8TypeAlias · 0.85
customInt16TypeAlias · 0.85
customInt32TypeAlias · 0.85
customInt64TypeAlias · 0.85
customUIntTypeAlias · 0.85
customUInt8TypeAlias · 0.85
customUInt16TypeAlias · 0.85
customUInt32TypeAlias · 0.85
customUInt64TypeAlias · 0.85
customFloat32TypeAlias · 0.85

Tested by

no test coverage detected