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

Function TestIsDecreasing

internal/testify/assert/assertion_order_test.go:98–141  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

96}
97
98func TestIsDecreasing(t *testing.T) {
99 mockT := new(testing.T)
100
101 if !IsDecreasing(mockT, []int{2, 1}) {
102 t.Error("IsDecreasing should return true")
103 }
104
105 if !IsDecreasing(mockT, []int{5, 4, 3, 2, 1}) {
106 t.Error("IsDecreasing should return true")
107 }
108
109 if IsDecreasing(mockT, []int{1, 1}) {
110 t.Error("IsDecreasing should return false")
111 }
112
113 if IsDecreasing(mockT, []int{1, 2}) {
114 t.Error("IsDecreasing should return false")
115 }
116
117 // Check error report
118 for _, currCase := range []struct {
119 collection interface{}
120 msg string
121 }{
122 {collection: []string{"a", "b"}, msg: `"a" is not greater than "b"`},
123 {collection: []int{1, 2}, msg: `"1" is not greater than "2"`},
124 {collection: []int{1, 2, 7, 6, 5, 4, 3}, msg: `"1" is not greater than "2"`},
125 {collection: []int{5, 4, 3, 1, 2}, msg: `"1" is not greater than "2"`},
126 {collection: []int8{1, 2}, msg: `"1" is not greater than "2"`},
127 {collection: []int16{1, 2}, msg: `"1" is not greater than "2"`},
128 {collection: []int32{1, 2}, msg: `"1" is not greater than "2"`},
129 {collection: []int64{1, 2}, msg: `"1" is not greater than "2"`},
130 {collection: []uint8{1, 2}, msg: `"1" is not greater than "2"`},
131 {collection: []uint16{1, 2}, msg: `"1" is not greater than "2"`},
132 {collection: []uint32{1, 2}, msg: `"1" is not greater than "2"`},
133 {collection: []uint64{1, 2}, msg: `"1" is not greater than "2"`},
134 {collection: []float32{1.23, 2.34}, msg: `"1.23" is not greater than "2.34"`},
135 {collection: []float64{1.23, 2.34}, msg: `"1.23" is not greater than "2.34"`},
136 } {
137 out := &outputT{buf: bytes.NewBuffer(nil)}
138 False(t, IsDecreasing(out, currCase.collection))
139 Contains(t, out.buf.String(), currCase.msg)
140 }
141}
142
143func TestIsNonDecreasing(t *testing.T) {
144 mockT := new(testing.T)

Callers

nothing calls this directly

Calls 5

IsDecreasingFunction · 0.70
FalseFunction · 0.70
ContainsFunction · 0.70
StringMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…