-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalue_equal_test.go
More file actions
64 lines (62 loc) · 1019 Bytes
/
value_equal_test.go
File metadata and controls
64 lines (62 loc) · 1019 Bytes
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
package utils
import "testing"
func TestValueEqual(t *testing.T) {
type args[T any] struct {
a *T
b *T
}
type testCase[T any] struct {
name string
args args[T]
want bool
}
tests := []testCase[string]{
{
name: "nil-both",
args: struct {
a *string
b *string
}{a: nil, b: nil},
want: true,
},
{
name: "nil-a",
args: struct {
a *string
b *string
}{a: nil, b: Ptr("xd")},
want: false,
},
{
name: "nil-b",
args: struct {
a *string
b *string
}{a: Ptr("xd"), b: nil},
want: false,
},
{
name: "different",
args: struct {
a *string
b *string
}{a: Ptr("xd"), b: Ptr("dx")},
want: false,
},
{
name: "equal",
args: struct {
a *string
b *string
}{a: Ptr("xd"), b: Ptr("xd")},
want: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := ValueEqual(tt.args.a, tt.args.b); got != tt.want {
t.Errorf("ValueEqual() = %v, want %v", got, tt.want)
}
})
}
}