Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TEST] example for enums in namespaces #131

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions tests/test_code_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ def test_enums():
include_dirs,
)

assert mod.Foo.MyEnum
assert mod.Foo.MyEnum.B
assert mod.Foo2.MyEnum
assert mod.Foo2.MyEnum.D

foo = mod.Foo()
my_enum = mod.Foo.MyEnum
assert "Testing Enum documentation." in my_enum.__doc__
Expand Down
11 changes: 10 additions & 1 deletion tests/test_files/enums.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,13 @@ class Foo
case MyEnum::C : return 3;
}
};
};
};

namespace Foo2
{

enum class MyEnum
{
A,C,D
};
};
32 changes: 28 additions & 4 deletions tests/test_files/enums.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,47 @@
cdef extern from "enums.hpp":
cdef cppclass Foo:

int enumToInt(MyEnum e)
int enumToInt(Foo__MyEnum e)

cdef extern from "enums.hpp":
cdef cppclass Foo2:
pass


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

cpdef enum class MyEnum "Foo::MyEnum":
cpdef enum Foo__MyEnum "Foo::MyEnum":
# wrap-attach:
# Foo
#
# wrap-as:
# MyEnum
#
# wrap-doc:
# Testing Enum documentation.
A
B
C

cpdef enum class MyEnum2 "Foo::MyEnum2":
cpdef enum MyEnum2 "Foo::MyEnum2":
# wrap-attach:
# Foo
A
B
C
C

cdef extern from "enums.hpp" namespace "Foo2":

cpdef enum Foo2__MyEnum "Foo2::MyEnum":
# wrap-attach:
# Foo2
#
# wrap-as:
# MyEnum
#
# wrap-doc:
# This is a second enum in another namespace.
A
C
D

Loading