...
1 package mergo_test
2
3 import (
4 "testing"
5
6 "github.com/imdario/mergo"
7 )
8
9 func 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
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
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 }
50
View as plain text