diff --git a/tests/test_code_generator.py b/tests/test_code_generator.py index 1b113935..9ca2596c 100644 --- a/tests/test_code_generator.py +++ b/tests/test_code_generator.py @@ -58,6 +58,11 @@ def test_enums(): mod = autowrap.Utils.compile_and_import("enummodule", [target, ], 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__ diff --git a/tests/test_files/enums.hpp b/tests/test_files/enums.hpp index 569bcf3f..a15d3156 100644 --- a/tests/test_files/enums.hpp +++ b/tests/test_files/enums.hpp @@ -20,4 +20,13 @@ class Foo case MyEnum::C : return 3; } }; -}; \ No newline at end of file +}; + +namespace Foo2 +{ + + enum class MyEnum + { + A,C,D + }; +}; diff --git a/tests/test_files/enums.pxd b/tests/test_files/enums.pxd index d2006ff6..67cf4c19 100644 --- a/tests/test_files/enums.pxd +++ b/tests/test_files/enums.pxd @@ -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 \ No newline at end of file + 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 +