-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgutil_z_unit_reflect_test.go
69 lines (64 loc) · 1.79 KB
/
gutil_z_unit_reflect_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// 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 (
"reflect"
"testing"
"github.com/gogf/gf/v2/test/gtest"
"github.com/gogf/gf/v2/util/gutil"
)
func Test_OriginValueAndKind(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
var s = "s"
out := gutil.OriginValueAndKind(s)
t.Assert(out.InputKind, reflect.String)
t.Assert(out.OriginKind, reflect.String)
})
gtest.C(t, func(t *gtest.T) {
var s = "s"
out := gutil.OriginValueAndKind(&s)
t.Assert(out.InputKind, reflect.Ptr)
t.Assert(out.OriginKind, reflect.String)
})
gtest.C(t, func(t *gtest.T) {
var s []int
out := gutil.OriginValueAndKind(s)
t.Assert(out.InputKind, reflect.Slice)
t.Assert(out.OriginKind, reflect.Slice)
})
gtest.C(t, func(t *gtest.T) {
var s []int
out := gutil.OriginValueAndKind(&s)
t.Assert(out.InputKind, reflect.Ptr)
t.Assert(out.OriginKind, reflect.Slice)
})
}
func Test_OriginTypeAndKind(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
var s = "s"
out := gutil.OriginTypeAndKind(s)
t.Assert(out.InputKind, reflect.String)
t.Assert(out.OriginKind, reflect.String)
})
gtest.C(t, func(t *gtest.T) {
var s = "s"
out := gutil.OriginTypeAndKind(&s)
t.Assert(out.InputKind, reflect.Ptr)
t.Assert(out.OriginKind, reflect.String)
})
gtest.C(t, func(t *gtest.T) {
var s []int
out := gutil.OriginTypeAndKind(s)
t.Assert(out.InputKind, reflect.Slice)
t.Assert(out.OriginKind, reflect.Slice)
})
gtest.C(t, func(t *gtest.T) {
var s []int
out := gutil.OriginTypeAndKind(&s)
t.Assert(out.InputKind, reflect.Ptr)
t.Assert(out.OriginKind, reflect.Slice)
})
}