Skip to content

Commit 7c3065d

Browse files
committed
feat: add more test and todo
1 parent 50a5d79 commit 7c3065d

File tree

5 files changed

+54
-31
lines changed

5 files changed

+54
-31
lines changed

tests/test_binding.py

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,47 @@
11
import numpy as np
22
from tests import test_module as tm
3-
import copy
3+
from tests.utils import generate_matrix, check_matrix_content
44

5-
def generate_matrix():
6-
return np.arange(10*10*3, dtype=np.uint16).reshape((10, 10, 3))
75

8-
9-
def check_matrix_content(mat):
10-
return np.any(generate_matrix() == mat)
11-
12-
13-
def test_python_utils():
14-
mat = generate_matrix()
15-
assert(check_matrix_content(mat))
16-
17-
18-
def test_from_python_to_cpp():
6+
def test_pass_py2cpp():
197
mat = generate_matrix()
208
assert(mat.shape == (10, 10, 3))
219
assert(mat.flags['C_CONTIGUOUS'])
2210
assert(mat.dtype == np.uint16)
2311
assert(tm.check_matrix_content(mat))
2412

2513

26-
def test_from_cpp_to_python():
14+
def test_pass_cpp2py():
2715
mat = tm.generate_matrix()
2816
assert(mat.shape == (10, 10, 3))
2917
assert(mat.flags['C_CONTIGUOUS'])
3018
assert(mat.dtype == np.uint16)
3119
assert(check_matrix_content(mat))
3220

3321

34-
def test_passthough():
22+
def test_passthough_cpp2cpp():
3523
mat = tm.generate_matrix()
3624
assert(mat.shape == (10, 10, 3))
25+
assert(mat.flags['C_CONTIGUOUS'])
3726
assert(check_matrix_content(mat))
3827
assert(tm.check_matrix_content(mat))
3928

29+
30+
def test_passthough_py2py():
31+
mat = generate_matrix()
32+
returned_mat = tm.passthru(mat)
33+
assert(mat.flags['C_CONTIGUOUS'])
34+
assert(mat.shape == (10, 10, 3))
35+
assert(check_matrix_content(mat))
36+
37+
38+
39+
40+
def test_slice():
41+
pass
42+
43+
44+
4045
def test_pointer():
4146
pass
4247

tests/test_return.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@
22
from tests import test_module as tm
33

44

5-
def test_return_by_ref():
6-
a = tm.ClassForReturn()
7-
assert(id(a.returnByRef()) == id(a.returnByRef()))
5+
# def test_return_by_ref():
6+
# a = tm.ClassForReturn()
7+
# assert(id(a.returnByRef()) == id(a.returnByRef()))
88

9-
def test_return_by_value():
10-
a = tm.ClassForReturn()
11-
assert(id(a.returnByValue()) != id(a.returnByValue()))
9+
# def test_return_by_value():
10+
# a = tm.ClassForReturn()
11+
# assert(id(a.returnByValue()) != id(a.returnByValue()))
1212

13-
def test_return_by_pointer():
14-
a = tm.ClassForReturn()
15-
assert(id(a.returnByPointer()) == id(a.returnByPointer()))
13+
# def test_return_by_pointer():
14+
# a = tm.ClassForReturn()
15+
# assert(id(a.returnByPointer()) == id(a.returnByPointer()))
1616

17-
def test_return_by_argument_by_ref():
18-
pass
17+
# def test_return_by_argument_by_ref():
18+
# pass
1919

20-
def test_return_by_argument_by_value():
21-
pass
20+
# def test_return_by_argument_by_value():
21+
# pass
2222

23-
def test_return_by_argument_by_pointer():
24-
pass
23+
# def test_return_by_argument_by_pointer():
24+
# pass

tests/test_slice.py

Whitespace-only changes.

tests/test_type.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import numpy as np
2+
from tests import test_module as tm
3+
from tests.utils import generate_matrix, check_matrix_content
4+
5+
def test_type_uint8_py2cpp():
6+
pass
7+
8+
def test_type_uint8_py2cpp():
9+
pass

tests/utils.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import numpy as np
2+
3+
4+
def generate_matrix():
5+
return np.arange(10*10*3, dtype=np.uint16).reshape((10, 10, 3))
6+
7+
8+
def check_matrix_content(mat):
9+
return np.any(generate_matrix() == mat)

0 commit comments

Comments
 (0)