-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtype_test.go
61 lines (55 loc) · 1.02 KB
/
type_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
package python_test
import (
"testing"
"github.com/stretchr/testify/assert"
python3 "go.nhat.io/python/v3"
)
func TestTypeName(t *testing.T) {
testCases := []struct {
scenario string
value *python3.Object
expected string
}{
{
scenario: "bool",
value: python3.NewBool(true),
expected: "bool",
},
{
scenario: "string",
value: python3.NewString("hello"),
expected: "str",
},
{
scenario: "int",
value: python3.NewInt(42),
expected: "int",
},
{
scenario: "int64",
value: python3.NewInt64(42),
expected: "int",
},
{
scenario: "float",
value: python3.NewFloat64(3.14),
expected: "float",
},
{
scenario: "list",
value: python3.NewList(1).AsObject(),
expected: "list",
},
{
scenario: "tuple",
value: python3.NewTuple(1).AsObject(),
expected: "tuple",
},
}
for _, tc := range testCases {
t.Run(tc.scenario, func(t *testing.T) {
actual := python3.TypeName(tc.value)
assert.Equal(t, tc.expected, actual)
})
}
}