mirror of
https://gitee.com/johng/gf.git
synced 2024-12-05 05:37:55 +08:00
38 lines
729 B
Go
Executable File
38 lines
729 B
Go
Executable File
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
|
|
//
|
|
// This Source Code Form is subject to the terms of the MIT License.
|
|
// If a copy of the MIT was not distributed with this file,
|
|
// You can obtain one at https://github.com/gogf/gf.
|
|
|
|
package gutil_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/gogf/gf/v2/frame/g"
|
|
"github.com/gogf/gf/v2/test/gtest"
|
|
"github.com/gogf/gf/v2/util/gutil"
|
|
)
|
|
|
|
func Test_Copy(t *testing.T) {
|
|
gtest.C(t, func(t *gtest.T) {
|
|
src := g.Map{
|
|
"k1": "v1",
|
|
"k2": "v2",
|
|
}
|
|
dst := gutil.Copy(src)
|
|
t.Assert(dst, src)
|
|
|
|
dst.(g.Map)["k3"] = "v3"
|
|
t.Assert(src, g.Map{
|
|
"k1": "v1",
|
|
"k2": "v2",
|
|
})
|
|
t.Assert(dst, g.Map{
|
|
"k1": "v1",
|
|
"k2": "v2",
|
|
"k3": "v3",
|
|
})
|
|
})
|
|
}
|