test_std_unique_ptr.py
Go to the documentation of this file.
1 from std_unique_ptr import (
2  V1,
3  UniquePtrHolder,
4  make_unique_complex,
5  make_unique_int,
6  make_unique_null,
7  make_unique_str,
8  make_unique_v1,
9 )
10 
12 assert isinstance(v, int)
13 assert v == 10
14 
15 v = make_unique_v1()
16 assert isinstance(v, V1)
17 assert v.v == 10
18 
19 v = make_unique_null()
20 assert v is None
21 
22 v = make_unique_str()
23 assert isinstance(v, str)
24 assert v == "str"
25 
27 assert isinstance(v, complex)
28 assert v == 1 + 0j
29 
30 unique_ptr_holder = UniquePtrHolder()
31 
32 v = unique_ptr_holder.int_ptr
33 assert isinstance(v, int)
34 assert v == 20
35 # v is a copy, int_ptr will not be updated
36 v = 10
37 assert unique_ptr_holder.int_ptr == 20
38 
39 v = unique_ptr_holder.v1_ptr
40 assert isinstance(v, V1)
41 assert v.v == 200
42 # v is a ref, v1_ptr will be updated
43 v.v = 10
44 assert unique_ptr_holder.v1_ptr.v == 10
45 
46 v = unique_ptr_holder.null_ptr
47 assert v is None
48 
49 v = unique_ptr_holder.str_ptr
50 assert isinstance(v, str)
51 assert v == "str"
52 # v is a copy, str_ptr will not be updated
53 v = "str_updated"
54 assert unique_ptr_holder.str_ptr == "str"
55 
56 v = unique_ptr_holder.complex_ptr
57 assert isinstance(v, complex)
58 assert v == 1 + 0j
59 # v is a copy, complex_ptr will not be updated
60 v = 1 + 2j
61 assert unique_ptr_holder.complex_ptr == 1 + 0j
make_unique_null
std::unique_ptr< V1 > make_unique_null()
Definition: std_unique_ptr.cpp:24
make_unique_v1
std::unique_ptr< V1 > make_unique_v1()
Definition: std_unique_ptr.cpp:22
make_unique_int
std::unique_ptr< int > make_unique_int()
Definition: std_unique_ptr.cpp:20
make_unique_str
std::unique_ptr< std::string > make_unique_str()
Definition: std_unique_ptr.cpp:26
make_unique_complex
std::unique_ptr< std::complex< double > > make_unique_complex()
Definition: std_unique_ptr.cpp:30


eigenpy
Author(s): Justin Carpentier, Nicolas Mansard
autogenerated on Fri Jun 14 2024 02:15:58