Stephane Barbarie | ec0919b | 2018-09-05 14:14:29 -0400 | [diff] [blame^] | 1 | package model |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | "github.com/opencord/voltha-go/protos/voltha" |
| 6 | "reflect" |
| 7 | ) |
| 8 | |
| 9 | func Test_Utils_Clone(t *testing.T) { |
| 10 | a := &voltha.Device{ |
| 11 | Id: "abcde", |
| 12 | FirmwareVersion: "someversion", |
| 13 | } |
| 14 | b:= &voltha.Device{} |
| 15 | Clone(reflect.ValueOf(a).Interface(), b) |
| 16 | t.Logf("A: %+v, B: %+v", a, b) |
| 17 | b.Id = "12345" |
| 18 | t.Logf("A: %+v, B: %+v", a, b) |
| 19 | |
| 20 | var c *voltha.Device |
| 21 | c = Clone2(a).(*voltha.Device) |
| 22 | t.Logf("A: %+v, C: %+v", a, c) |
| 23 | c.Id = "12345" |
| 24 | t.Logf("A: %+v, C: %+v", a, c) |
| 25 | } |