Stephane Barbarie | 694e2b9 | 2018-09-07 12:17:36 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018-present Open Networking Foundation |
| 3 | |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Stephane Barbarie | ec0919b | 2018-09-05 14:14:29 -0400 | [diff] [blame] | 16 | package model |
| 17 | |
| 18 | import ( |
Stephane Barbarie | ec0919b | 2018-09-05 14:14:29 -0400 | [diff] [blame] | 19 | "github.com/opencord/voltha-go/protos/voltha" |
| 20 | "reflect" |
khenaidoo | b920354 | 2018-09-17 22:56:37 -0400 | [diff] [blame] | 21 | "testing" |
Stephane Barbarie | ec0919b | 2018-09-05 14:14:29 -0400 | [diff] [blame] | 22 | ) |
| 23 | |
| 24 | func Test_Utils_Clone(t *testing.T) { |
| 25 | a := &voltha.Device{ |
khenaidoo | b920354 | 2018-09-17 22:56:37 -0400 | [diff] [blame] | 26 | Id: "abcde", |
Stephane Barbarie | ec0919b | 2018-09-05 14:14:29 -0400 | [diff] [blame] | 27 | FirmwareVersion: "someversion", |
| 28 | } |
khenaidoo | b920354 | 2018-09-17 22:56:37 -0400 | [diff] [blame] | 29 | b := &voltha.Device{} |
Stephane Barbarie | ec0919b | 2018-09-05 14:14:29 -0400 | [diff] [blame] | 30 | Clone(reflect.ValueOf(a).Interface(), b) |
| 31 | t.Logf("A: %+v, B: %+v", a, b) |
| 32 | b.Id = "12345" |
| 33 | t.Logf("A: %+v, B: %+v", a, b) |
| 34 | |
| 35 | var c *voltha.Device |
| 36 | c = Clone2(a).(*voltha.Device) |
| 37 | t.Logf("A: %+v, C: %+v", a, c) |
| 38 | c.Id = "12345" |
| 39 | t.Logf("A: %+v, C: %+v", a, c) |
| 40 | } |