MCPcopy
hub / github.com/darccio/mergo / TestIssue129Boolean

Function TestIssue129Boolean

issue129_test.go:9–49  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func TestIssue129Boolean(t *testing.T) {
10 type Foo struct {
11 A bool
12 B bool
13 }
14
15 src := Foo{
16 A: true,
17 B: false,
18 }
19 dst := Foo{
20 A: false,
21 B: true,
22 }
23
24 // Standard behavior
25 if err := mergo.Merge(&dst, src); err != nil {
26 t.Error(err)
27 }
28 if dst.A != true {
29 t.Errorf("expected true, got false")
30 }
31 if dst.B != true {
32 t.Errorf("expected true, got false")
33 }
34
35 // Expected behavior
36 dst = Foo{
37 A: false,
38 B: true,
39 }
40 if err := mergo.Merge(&dst, src, mergo.WithOverwriteWithEmptyValue); err != nil {
41 t.Error(err)
42 }
43 if dst.A != true {
44 t.Errorf("expected true, got false")
45 }
46 if dst.B != false {
47 t.Errorf("expected false, got true")
48 }
49}

Callers

nothing calls this directly

Calls 1

MergeFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…