MCPcopy
hub / github.com/TomWright/dasel / TestValue_LessThan

Function TestValue_LessThan

model/value_comparison_test.go:285–388  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

283}
284
285func TestValue_LessThan(t *testing.T) {
286 run := func(tc compareTestCase) func(t *testing.T) {
287 return func(t *testing.T) {
288 got, err := tc.a.LessThan(tc.b)
289 if err != nil {
290 t.Errorf("unexpected error: %s", err)
291 return
292 }
293 gotBool, err := got.BoolValue()
294 if err != nil {
295 t.Errorf("unexpected error: %s", err)
296 return
297 }
298 if gotBool != tc.exp {
299 t.Errorf("expected %v, got %v", tc.exp, got)
300 }
301 }
302 }
303 t.Run("int", func(t *testing.T) {
304 t.Run("less", run(compareTestCase{
305 a: model.NewIntValue(1),
306 b: model.NewIntValue(2),
307 exp: true,
308 }))
309 t.Run("greater", run(compareTestCase{
310 a: model.NewIntValue(2),
311 b: model.NewIntValue(1),
312 exp: false,
313 }))
314 t.Run("equal", run(compareTestCase{
315 a: model.NewIntValue(1),
316 b: model.NewIntValue(1),
317 exp: false,
318 }))
319 })
320 t.Run("float", func(t *testing.T) {
321 t.Run("less", run(compareTestCase{
322 a: model.NewFloatValue(1.1),
323 b: model.NewFloatValue(1.2),
324 exp: true,
325 }))
326 t.Run("greater", run(compareTestCase{
327 a: model.NewFloatValue(1.2),
328 b: model.NewFloatValue(1.1),
329 exp: false,
330 }))
331 t.Run("equal", run(compareTestCase{
332 a: model.NewFloatValue(1.1),
333 b: model.NewFloatValue(1.1),
334 exp: false,
335 }))
336 })
337 t.Run("int float", func(t *testing.T) {
338 t.Run("less", run(compareTestCase{
339 a: model.NewIntValue(1),
340 b: model.NewFloatValue(2),
341 exp: true,
342 }))

Callers

nothing calls this directly

Calls 7

NewIntValueFunction · 0.92
NewFloatValueFunction · 0.92
NewStringValueFunction · 0.92
runFunction · 0.85
LessThanMethod · 0.80
BoolValueMethod · 0.80
RunMethod · 0.45

Tested by

no test coverage detected