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

Function TestGreater

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

Source from the content-addressed store, hash-verified

129}
130
131func TestGreater(t *testing.T) {
132 t.Parallel()
133
134 mockT := new(testing.T)
135
136 if !Greater(mockT, 2, 1) {
137 t.Error("Greater should return true")
138 }
139
140 if Greater(mockT, 1, 1) {
141 t.Error("Greater should return false")
142 }
143
144 if Greater(mockT, 1, 2) {
145 t.Error("Greater should return false")
146 }
147
148 // Check error report
149 for _, currCase := range []struct {
150 less interface{}
151 greater interface{}
152 msg string
153 }{
154 {less: "a", greater: "b", msg: `"a" is not greater than "b"`},
155 {less: int(1), greater: int(2), msg: `"1" is not greater than "2"`},
156 {less: int8(1), greater: int8(2), msg: `"1" is not greater than "2"`},
157 {less: int16(1), greater: int16(2), msg: `"1" is not greater than "2"`},
158 {less: int32(1), greater: int32(2), msg: `"1" is not greater than "2"`},
159 {less: int64(1), greater: int64(2), msg: `"1" is not greater than "2"`},
160 {less: uint8(1), greater: uint8(2), msg: `"1" is not greater than "2"`},
161 {less: uint16(1), greater: uint16(2), msg: `"1" is not greater than "2"`},
162 {less: uint32(1), greater: uint32(2), msg: `"1" is not greater than "2"`},
163 {less: uint64(1), greater: uint64(2), msg: `"1" is not greater than "2"`},
164 {less: float32(1.23), greater: float32(2.34), msg: `"1.23" is not greater than "2.34"`},
165 {less: float64(1.23), greater: float64(2.34), msg: `"1.23" is not greater than "2.34"`},
166 {less: uintptr(1), greater: uintptr(2), msg: `"1" is not greater than "2"`},
167 {less: time.Time{}, greater: time.Time{}.Add(time.Hour), msg: `"0001-01-01 00:00:00 +0000 UTC" is not greater than "0001-01-01 01:00:00 +0000 UTC"`},
168 {less: []byte{1, 1}, greater: []byte{1, 2}, msg: `"[1 1]" is not greater than "[1 2]"`},
169 } {
170 out := &outputT{buf: bytes.NewBuffer(nil)}
171 False(t, Greater(out, currCase.less, currCase.greater))
172 Contains(t, out.buf.String(), currCase.msg)
173 Contains(t, out.helpers, "github.com/stretchr/testify/assert.Greater")
174 }
175}
176
177func TestGreaterOrEqual(t *testing.T) {
178 t.Parallel()

Callers

nothing calls this directly

Calls 5

GreaterFunction · 0.70
FalseFunction · 0.70
ContainsFunction · 0.70
ErrorMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected