-
Notifications
You must be signed in to change notification settings - Fork 0
/
integer_test.v
79 lines (69 loc) · 1.64 KB
/
integer_test.v
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
module py
fn testsuite_begin() {
C.Py_Initialize()
}
fn testsuite_end() {
}
fn test_long_check() {
l := C.PyLong_FromLong(4242)
assert C.PyLong_Check(l) == 1
assert C.PyLong_CheckExact(l) == 1
C.Py_XDECREF(l)
}
fn test_long_from_long() {
val := int(4242)
py_l := C.PyLong_FromLong(val)
assert voidptr(py_l) != C.NULL
v_l := C.PyLong_AsLong(py_l)
assert v_l == val
C.Py_XDECREF(py_l)
}
fn test_long_from_ulong() {
val := u32(4242)
py_l := C.PyLong_FromUnsignedLong(val)
assert voidptr(py_l) != C.NULL
v_l := C.PyLong_AsUnsignedLong(py_l)
assert v_l == val
C.Py_XDECREF(py_l)
}
fn test_long_from_long_long() {
val := i64(4242)
py_l := C.PyLong_FromLongLong(val)
assert voidptr(py_l) != C.NULL
v_l := C.PyLong_AsLongLong(py_l)
assert v_l == val
C.Py_XDECREF(py_l)
}
fn test_long_from_u_long_long() {
val := u64(4242)
py_l := C.PyLong_FromUnsignedLongLong(val)
assert voidptr(py_l) != C.NULL
v_l := C.PyLong_AsUnsignedLongLong(py_l)
assert v_l == val
C.Py_XDECREF(py_l)
}
fn test_long_from_float() {
val := f64(4242)
py_l := C.PyLong_FromDouble(val)
assert voidptr(py_l) != C.NULL
v_l := C.PyLong_AsDouble(py_l)
assert v_l == val
C.Py_XDECREF(py_l)
}
fn test_long_from_string() {
val := 4242
val_str := val.str()
py_l := C.PyLong_FromString(val_str.str, C.NULL, 10)
assert voidptr(py_l) != C.NULL
v_l := C.PyLong_AsLong(py_l)
assert v_l == val
C.Py_XDECREF(py_l)
}
fn test_long_from_voidptr() {
val := 4242
py_l := C.PyLong_FromVoidPtr(voidptr(val))
assert voidptr(py_l) != C.NULL
v_l := C.PyLong_AsLong(py_l)
assert v_l == val
C.Py_XDECREF(py_l)
}