test_optional_std.py
Go to the documentation of this file.
1 import importlib
2 
3 bind_optional = importlib.import_module("bind_optional_std")
4 
5 
7  x = bind_optional.none_if_zero(0)
8  y = bind_optional.none_if_zero(-1)
9  assert x is None
10  assert y == -1
11 
12 
14  # test struct ctors
15 
16  struct = bind_optional.mystruct()
17  assert struct.a is None
18  assert struct.b is None
19  assert struct.msg == "i am struct"
20 
21 
22  struct = bind_optional.mystruct(2)
23  assert struct.a == 2
24  assert struct.b is None
25 
26  struct = bind_optional.mystruct(13, -1.0)
27  assert struct.a == 13
28  assert struct.b == -1.0
29 
30 
32  struct = bind_optional.mystruct()
33  struct.a = 1
34  assert struct.a == 1
35 
36  struct.b = -3.14
37  assert struct.b == -3.14
38 
39  # set to None
40  struct.a = None
41  struct.b = None
42  struct.msg = None
43  assert struct.a is None
44  assert struct.b is None
45  assert struct.msg is None
46 
47 
49  struct = bind_optional.create_if_true(False, None)
50  assert struct is None
51  struct = bind_optional.create_if_true(True, None)
52  assert struct.a == 0
53  assert struct.b is None
54 
55 
57  M = bind_optional.random_mat_if_true(False)
58  assert M is None
59  M = bind_optional.random_mat_if_true(True)
60  assert M.shape == (4, 4)
61 
62 


eigenpy
Author(s): Justin Carpentier, Nicolas Mansard
autogenerated on Fri Jun 2 2023 02:10:26