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

Function TestValue_Subtract

model/value_math_test.go:40–66  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

38}
39
40func TestValue_Subtract(t *testing.T) {
41 run := func(a, b *model.Value, exp *model.Value) func(*testing.T) {
42 return func(t *testing.T) {
43 got, err := a.Subtract(b)
44 if err != nil {
45 t.Errorf("unexpected error: %s", err)
46 return
47 }
48 eq, err := got.EqualTypeValue(exp)
49 if err != nil {
50 t.Errorf("unexpected error: %s", err)
51 return
52 }
53 if !eq {
54 t.Errorf("expected %v, got %v", exp, got)
55 }
56 }
57 }
58 t.Run("int", func(t *testing.T) {
59 t.Run("int", run(model.NewIntValue(3), model.NewIntValue(2), model.NewIntValue(1)))
60 t.Run("float", run(model.NewIntValue(3), model.NewFloatValue(2), model.NewFloatValue(1)))
61 })
62 t.Run("float", func(t *testing.T) {
63 t.Run("int", run(model.NewFloatValue(3), model.NewIntValue(2), model.NewFloatValue(1)))
64 t.Run("float", run(model.NewFloatValue(3), model.NewFloatValue(2), model.NewFloatValue(1)))
65 })
66}
67
68func TestValue_Multiply(t *testing.T) {
69 run := func(a, b *model.Value, exp *model.Value) func(*testing.T) {

Callers

nothing calls this directly

Calls 6

NewIntValueFunction · 0.92
NewFloatValueFunction · 0.92
runFunction · 0.85
SubtractMethod · 0.80
EqualTypeValueMethod · 0.80
RunMethod · 0.45

Tested by

no test coverage detected