-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbool_test.go
32 lines (24 loc) · 923 Bytes
/
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
package python_test
import (
"testing"
"github.com/stretchr/testify/assert"
python3 "go.nhat.io/python/v3"
)
func TestBool(t *testing.T) {
boolT := python3.NewBool(true)
boolF := python3.NewBool(false)
assert.True(t, python3.IsBool(boolT))
assert.True(t, python3.IsBool(boolF))
assert.False(t, python3.IsBool(python3.NewInt(0)))
assert.False(t, python3.IsBool(python3.NewString("")))
assert.True(t, python3.AsBool(boolT))
assert.False(t, python3.AsBool(boolF))
assert.False(t, python3.AsBool(python3.NewInt(1)))
assert.False(t, python3.AsBool(python3.NewInt(0)))
assert.False(t, python3.IsBool(python3.NewList(10)))
assert.False(t, python3.IsBool(python3.NewTuple(10)))
assert.False(t, python3.IsBool(python3.NewInt(42)))
assert.False(t, python3.IsBool(python3.NewInt64(42)))
assert.False(t, python3.IsBool(python3.NewString("hello")))
assert.False(t, python3.IsBool(python3.NewFloat64(3.14)))
}