forked from Nerzal/gocloak
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils_test.go
116 lines (98 loc) · 2.07 KB
/
utils_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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package gocloak_test
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/Nerzal/gocloak/v8"
)
func TestStringP(t *testing.T) {
p := gocloak.StringP("test value")
assert.Equal(t, "test value", *p)
}
func TestPString(t *testing.T) {
p := "test value"
v := gocloak.PString(&p)
assert.Equal(t, p, v)
}
func TestPStringNil(t *testing.T) {
v := gocloak.PString(nil)
assert.Equal(t, "", v)
}
func TestBoolP(t *testing.T) {
p1 := gocloak.BoolP(false)
assert.False(t, *p1)
p2 := gocloak.BoolP(false)
assert.False(t, *p1)
assert.False(t, p1 == p2)
p := gocloak.BoolP(true)
assert.True(t, *p)
}
func TestPBool(t *testing.T) {
p := true
v := gocloak.PBool(&p)
assert.True(t, v)
p = false
v = gocloak.PBool(&p)
assert.False(t, v)
}
func TestIntP(t *testing.T) {
p := gocloak.IntP(42)
assert.Equal(t, 42, *p)
}
func TestInt32P(t *testing.T) {
v := int32(42)
p := gocloak.Int32P(v)
assert.Equal(t, v, *p)
}
func TestInt64P(t *testing.T) {
v := int64(42)
p := gocloak.Int64P(v)
assert.Equal(t, v, *p)
}
func TestPInt(t *testing.T) {
p := 42
v := gocloak.PInt(&p)
assert.Equal(t, p, v)
assert.IsType(t, p, v)
}
func TestPInt32(t *testing.T) {
var p int32 = 42
v := gocloak.PInt32(&p)
assert.Equal(t, p, v)
assert.IsType(t, p, v)
}
func TestPInt64(t *testing.T) {
var p int64 = 42
v := gocloak.PInt64(&p)
assert.Equal(t, p, v)
assert.IsType(t, p, v)
}
func TestFloat32P(t *testing.T) {
v := float32(42.42)
p := gocloak.Float32P(v)
assert.Equal(t, v, *p)
}
func TestFloat64P(t *testing.T) {
v := 42.42
p := gocloak.Float64P(v)
assert.Equal(t, v, *p)
}
func TestPFloat32(t *testing.T) {
var p float32 = 42.42
v := gocloak.PFloat32(&p)
assert.Equal(t, p, v)
assert.IsType(t, p, v)
}
func TestPFloat64(t *testing.T) {
p := 42.42
v := gocloak.PFloat64(&p)
assert.Equal(t, p, v)
assert.IsType(t, p, v)
}
func TestNilOrEmptyArray(t *testing.T) {
a := gocloak.NilOrEmptyArray(&[]string{"c", "d"})
b := gocloak.NilOrEmptyArray(&[]string{"", "b"})
c := gocloak.NilOrEmptyArray(&[]string{})
assert.False(t, a)
assert.True(t, b)
assert.True(t, c)
}