Skip to content

Commit bcbff3f

Browse files
hroestjpfeuffer
authored andcommitted
[TEST] example for enums in namespaces
1 parent 570a6f4 commit bcbff3f

File tree

3 files changed

+43
-5
lines changed

3 files changed

+43
-5
lines changed

tests/test_code_generator.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ def test_enums():
6666
include_dirs,
6767
)
6868

69+
assert mod.Foo.MyEnum
70+
assert mod.Foo.MyEnum.B
71+
assert mod.Foo2.MyEnum
72+
assert mod.Foo2.MyEnum.D
73+
6974
foo = mod.Foo()
7075
my_enum = mod.Foo.MyEnum
7176
assert "Testing Enum documentation." in my_enum.__doc__

tests/test_files/enums.hpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,13 @@ class Foo
2020
case MyEnum::C : return 3;
2121
}
2222
};
23-
};
23+
};
24+
25+
namespace Foo2
26+
{
27+
28+
enum class MyEnum
29+
{
30+
A,C,D
31+
};
32+
};

tests/test_files/enums.pxd

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,47 @@
33
cdef extern from "enums.hpp":
44
cdef cppclass Foo:
55

6-
int enumToInt(MyEnum e)
6+
int enumToInt(Foo__MyEnum e)
7+
8+
cdef extern from "enums.hpp":
9+
cdef cppclass Foo2:
10+
pass
11+
712

813
cdef extern from "enums.hpp" namespace "Foo":
914

10-
cpdef enum class MyEnum "Foo::MyEnum":
15+
cpdef enum Foo__MyEnum "Foo::MyEnum":
1116
# wrap-attach:
1217
# Foo
1318
#
19+
# wrap-as:
20+
# MyEnum
21+
#
1422
# wrap-doc:
1523
# Testing Enum documentation.
1624
A
1725
B
1826
C
1927

20-
cpdef enum class MyEnum2 "Foo::MyEnum2":
28+
cpdef enum MyEnum2 "Foo::MyEnum2":
2129
# wrap-attach:
2230
# Foo
2331
A
2432
B
25-
C
33+
C
34+
35+
cdef extern from "enums.hpp" namespace "Foo2":
36+
37+
cpdef enum Foo2__MyEnum "Foo2::MyEnum":
38+
# wrap-attach:
39+
# Foo2
40+
#
41+
# wrap-as:
42+
# MyEnum
43+
#
44+
# wrap-doc:
45+
# This is a second enum in another namespace.
46+
A
47+
C
48+
D
49+

0 commit comments

Comments
 (0)