From 5edc00e7feed5fe5ba5764901a55ef9bb5f7cb9e Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Fri, 27 Aug 2010 00:43:25 -0700 Subject: [PATCH] C++ namespace tests. --- tests/run/cpp_namespaces.pyx | 28 ++++++++++++++++++++++++++++ tests/run/cpp_namespaces_helper.h | 25 +++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 tests/run/cpp_namespaces.pyx create mode 100644 tests/run/cpp_namespaces_helper.h diff --git a/tests/run/cpp_namespaces.pyx b/tests/run/cpp_namespaces.pyx new file mode 100644 index 00000000..e76a1d09 --- /dev/null +++ b/tests/run/cpp_namespaces.pyx @@ -0,0 +1,28 @@ +cdef extern from "cpp_namespaces_helper.h" namespace "A": + ctypedef int A_t + A_t A_func(A_t first, A_t) + +cdef extern from "cpp_namespaces_helper.h" namespace "outer": + int outer_value + +cdef extern from "cpp_namespaces_helper.h" namespace "outer::inner": + int inner_value + +def test_function(x, y): + """ + >>> test_function(1, 2) + 3 + >>> test_function(9, 16) + 25 + """ + return A_func(x, y) + +def test_nested(): + """ + >>> test_nested() + 10 + 100 + """ + print outer_value + print inner_value + diff --git a/tests/run/cpp_namespaces_helper.h b/tests/run/cpp_namespaces_helper.h new file mode 100644 index 00000000..1a7f8ace --- /dev/null +++ b/tests/run/cpp_namespaces_helper.h @@ -0,0 +1,25 @@ +namespace outer { + + int x = 10; + + int outer_value = 10; + + namespace inner { + + int x = 100; + + int inner_value = 100; + + } + +} + +namespace A { + + typedef int A_t; + + A_t A_func(A_t first, A_t second) { + return first + second; + } + +} -- 2.26.2