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

Function TestValue_Add

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

Source from the content-addressed store, hash-verified

7)
8
9func TestValue_Add(t *testing.T) {
10 run := func(a, b *model.Value, exp *model.Value) func(*testing.T) {
11 return func(t *testing.T) {
12 got, err := a.Add(b)
13 if err != nil {
14 t.Errorf("unexpected error: %s", err)
15 return
16 }
17 eq, err := got.EqualTypeValue(exp)
18 if err != nil {
19 t.Errorf("unexpected error: %s", err)
20 return
21 }
22 if !eq {
23 t.Errorf("expected %v, got %v", exp, got)
24 }
25 }
26 }
27 t.Run("int", func(t *testing.T) {
28 t.Run("int", run(model.NewIntValue(1), model.NewIntValue(2), model.NewIntValue(3)))
29 t.Run("float", run(model.NewIntValue(1), model.NewFloatValue(2), model.NewFloatValue(3)))
30 })
31 t.Run("float", func(t *testing.T) {
32 t.Run("int", run(model.NewFloatValue(1), model.NewIntValue(2), model.NewFloatValue(3)))
33 t.Run("float", run(model.NewFloatValue(1), model.NewFloatValue(2), model.NewFloatValue(3)))
34 })
35 t.Run("string", func(t *testing.T) {
36 t.Run("string", run(model.NewStringValue("hello"), model.NewStringValue(" world"), model.NewStringValue("hello world")))
37 })
38}
39
40func TestValue_Subtract(t *testing.T) {
41 run := func(a, b *model.Value, exp *model.Value) func(*testing.T) {

Callers

nothing calls this directly

Calls 7

NewIntValueFunction · 0.92
NewFloatValueFunction · 0.92
NewStringValueFunction · 0.92
runFunction · 0.85
AddMethod · 0.80
EqualTypeValueMethod · 0.80
RunMethod · 0.45

Tested by

no test coverage detected