-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbool_test.go
49 lines (45 loc) · 1.05 KB
/
bool_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
package pointerhelpers
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestBool(t *testing.T) {
h := BoolHelper{}
want := true
got := h.Bool(want)
assert.True(t, *got)
}
func TestBoolValue(t *testing.T) {
t.Run("when nil returns false", func(t *testing.T) {
h := BoolHelper{}
got := h.BoolValue(nil)
assert.False(t, got)
})
t.Run("When true, returns true", func(t *testing.T) {
h := BoolHelper{}
got := h.BoolValue(Bool(true))
assert.True(t, got)
})
t.Run("When false, returns false", func(t *testing.T) {
h := BoolHelper{}
got := h.BoolValue(Bool(false))
assert.False(t, got)
})
}
func TestBoolIsUnset(t *testing.T) {
t.Run("when nil returns true", func(t *testing.T) {
h := BoolHelper{}
got := h.BoolIsUnset(nil)
assert.True(t, got)
})
t.Run("When true, returns false", func(t *testing.T) {
h := BoolHelper{}
got := h.BoolIsUnset(Bool(true))
assert.False(t, got)
})
t.Run("When false, returns false", func(t *testing.T) {
h := BoolHelper{}
got := h.BoolIsUnset(Bool(false))
assert.False(t, got)
})
}