Skip to content
Snippets Groups Projects
Unverified Commit b8004fee authored by Joris Vaillant's avatar Joris Vaillant
Browse files

cmake: Use generated tests

parent 7c39cd8b
No related branches found
No related tags found
No related merge requests found
Pipeline #35870 passed with warnings
...@@ -55,8 +55,11 @@ function(config_test test tagname opttype) ...@@ -55,8 +55,11 @@ function(config_test test tagname opttype)
configure_file(python/test_${test}.py.in configure_file(python/test_${test}.py.in
${CMAKE_CURRENT_BINARY_DIR}/python/${py_file}) ${CMAKE_CURRENT_BINARY_DIR}/python/${py_file})
add_lib_unit_test(${MODNAME}) add_lib_unit_test(${MODNAME})
add_python_unit_test("py-${test}-${tagname}" "unittest/python/${py_file}" set(PYTHON_TEST_NAME "py-${test}-${tagname}")
"unittest") add_test(NAME ${PYTHON_TEST_NAME}
COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/python/${py_file}")
compute_pythonpath(ENV_VARIABLES "unittest")
set_tests_properties(${PYTHON_TEST_NAME} PROPERTIES ENVIRONMENT "${ENV_VARIABLES}")
endfunction() endfunction()
config_test(variant boost "boost::variant") config_test(variant boost "boost::variant")
......
import importlib
bind_optional = importlib.import_module("bind_optional_boost")
def test_none_if_zero():
x = bind_optional.none_if_zero(0)
y = bind_optional.none_if_zero(-1)
assert x is None
assert y == -1
def test_struct_ctors():
# test struct ctors
struct = bind_optional.mystruct()
assert struct.a is None
assert struct.b is None
assert struct.msg == "i am struct"
## no 2nd arg automatic overload using bp::optional
struct = bind_optional.mystruct(2)
assert struct.a == 2
assert struct.b is None
struct = bind_optional.mystruct(13, -1.0)
assert struct.a == 13
assert struct.b == -1.0
def test_struct_setters():
struct = bind_optional.mystruct()
struct.a = 1
assert struct.a == 1
struct.b = -3.14
assert struct.b == -3.14
# set to None
struct.a = None
struct.b = None
struct.msg = None
assert struct.a is None
assert struct.b is None
assert struct.msg is None
def test_factory():
struct = bind_optional.create_if_true(False, None)
assert struct is None
struct = bind_optional.create_if_true(True, None)
assert struct.a == 0
assert struct.b is None
def test_random_mat():
M = bind_optional.random_mat_if_true(False)
assert M is None
M = bind_optional.random_mat_if_true(True)
assert M.shape == (4, 4)
test_none_if_zero()
test_struct_ctors()
test_struct_setters()
test_factory()
test_random_mat()
import importlib
bind_optional = importlib.import_module("bind_optional_std")
def test_none_if_zero():
x = bind_optional.none_if_zero(0)
y = bind_optional.none_if_zero(-1)
assert x is None
assert y == -1
def test_struct_ctors():
# test struct ctors
struct = bind_optional.mystruct()
assert struct.a is None
assert struct.b is None
assert struct.msg == "i am struct"
## no 2nd arg automatic overload using bp::optional
struct = bind_optional.mystruct(2)
assert struct.a == 2
assert struct.b is None
struct = bind_optional.mystruct(13, -1.0)
assert struct.a == 13
assert struct.b == -1.0
def test_struct_setters():
struct = bind_optional.mystruct()
struct.a = 1
assert struct.a == 1
struct.b = -3.14
assert struct.b == -3.14
# set to None
struct.a = None
struct.b = None
struct.msg = None
assert struct.a is None
assert struct.b is None
assert struct.msg is None
def test_factory():
struct = bind_optional.create_if_true(False, None)
assert struct is None
struct = bind_optional.create_if_true(True, None)
assert struct.a == 0
assert struct.b is None
def test_random_mat():
M = bind_optional.random_mat_if_true(False)
assert M is None
M = bind_optional.random_mat_if_true(True)
assert M.shape == (4, 4)
test_none_if_zero()
test_struct_ctors()
test_struct_setters()
test_factory()
test_random_mat()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment