blob: 618e15878a31b4e11c3515216e74001440d0ae5f [file] [log] [blame]
Stephane Barbarie694e2b92018-09-07 12:17:36 -04001/*
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 Barbarieec0919b2018-09-05 14:14:29 -040016package model
17
18import (
Stephane Barbarieec0919b2018-09-05 14:14:29 -040019 "github.com/opencord/voltha-go/protos/voltha"
20 "reflect"
khenaidoob9203542018-09-17 22:56:37 -040021 "testing"
Stephane Barbarieec0919b2018-09-05 14:14:29 -040022)
23
24func Test_Utils_Clone(t *testing.T) {
25 a := &voltha.Device{
khenaidoob9203542018-09-17 22:56:37 -040026 Id: "abcde",
Stephane Barbarieec0919b2018-09-05 14:14:29 -040027 FirmwareVersion: "someversion",
28 }
khenaidoob9203542018-09-17 22:56:37 -040029 b := &voltha.Device{}
Stephane Barbariedc5022d2018-11-19 15:21:44 -050030 clone(reflect.ValueOf(a).Interface(), b)
Stephane Barbarieec0919b2018-09-05 14:14:29 -040031 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
Stephane Barbariedc5022d2018-11-19 15:21:44 -050036 c = clone2(a).(*voltha.Device)
Stephane Barbarieec0919b2018-09-05 14:14:29 -040037 t.Logf("A: %+v, C: %+v", a, c)
38 c.Id = "12345"
39 t.Logf("A: %+v, C: %+v", a, c)
40}