blob: c4cc60d8dff142299a0a6771511ba9065edee14f [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 Barbarieec0919b2018-09-05 14:14:29 -040030 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}