-
-
Notifications
You must be signed in to change notification settings - Fork 282
Expand file tree
/
Copy pathissue129_test.go
More file actions
49 lines (43 loc) · 725 Bytes
/
issue129_test.go
File metadata and controls
49 lines (43 loc) · 725 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package mergo_test
import (
"testing"
"dario.cat/mergo"
)
func TestIssue129Boolean(t *testing.T) {
type Foo struct {
A bool
B bool
}
src := Foo{
A: true,
B: false,
}
dst := Foo{
A: false,
B: true,
}
// Standard behavior
if err := mergo.Merge(&dst, src); err != nil {
t.Error(err)
}
if dst.A != true {
t.Errorf("expected true, got false")
}
if dst.B != true {
t.Errorf("expected true, got false")
}
// Expected behavior
dst = Foo{
A: false,
B: true,
}
if err := mergo.Merge(&dst, src, mergo.WithOverwriteWithEmptyValue); err != nil {
t.Error(err)
}
if dst.A != true {
t.Errorf("expected true, got false")
}
if dst.B != false {
t.Errorf("expected false, got true")
}
}