MCPcopy
hub / github.com/expr-lang/expr / TestCompare

Function TestCompare

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 15

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
customFloat64TypeAlias · 0.85
customUintptrTypeAlias · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…