Changing the implementation of DeepCopy to use reflection instead of Gob encode/decode.

This commit is contained in:
Kris Rousey
2015-05-13 10:12:36 -07:00
parent 3481db8aee
commit 4d031abc16
3 changed files with 154 additions and 38 deletions

View File

@@ -108,6 +108,24 @@ func TestDeepCopyPointerSeparate(t *testing.T) {
}
}
func TestDeepCopyStruct(t *testing.T) {
type Foo struct {
A int
}
type Bar struct {
Foo
F *Foo
}
a := &Bar{Foo{1}, &Foo{2}}
b := copyOrDie(t, a).(*Bar)
a.A = 3
a.F.A = 4
if b.A != 1 || b.F.A != 2 {
t.Errorf("deep copy wasn't deep: %#v, %#v", a, b)
}
}
var result interface{}
func BenchmarkDeepCopy(b *testing.B) {