-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
parse_boolean_test.go
47 lines (40 loc) · 987 Bytes
/
parse_boolean_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
package jfather
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func Test_Boolean_True(t *testing.T) {
example := []byte(`true`)
var output bool
err := Unmarshal(example, &output)
require.NoError(t, err)
assert.True(t, output)
}
func Test_Boolean_False(t *testing.T) {
example := []byte(`false`)
var output bool
err := Unmarshal(example, &output)
require.NoError(t, err)
assert.False(t, output)
}
func Test_Boolean_ToNonBoolPointer(t *testing.T) {
example := []byte(`false`)
var output string
err := Unmarshal(example, &output)
require.Error(t, err)
}
func Test_Bool_ToUninitialisedPointer(t *testing.T) {
example := []byte(`true`)
var str *string
err := Unmarshal(example, str)
require.Error(t, err)
assert.Nil(t, str)
}
func Test_Bool_ToInterface(t *testing.T) {
example := []byte(`true`)
var output interface{}
err := Unmarshal(example, &output)
require.NoError(t, err)
assert.True(t, output.(bool))
}