Skip to content

Commit

Permalink
add tests for std::vector<>::value_type of array template arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
wlav committed Jul 18, 2021
1 parent ad9e613 commit 76f6b30
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/test_lowlevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,38 @@ def test13_array_interface(self):
a[0] = 5
assert b[0] == 5

def test14_templated_arrays(self):
"""Use of arrays in template types"""

import cppyy

assert cppyy.gbl.std.vector[int].value_type == 'int'
assert cppyy.gbl.std.vector[cppyy.gbl.std.vector[int]].value_type == 'std::vector<int>'
assert cppyy.gbl.std.vector['int[1]'].value_type == 'int[1]'

def test15_templated_arrays_gmpxx(self):
"""Use of gmpxx array types in templates"""

import cppyy

try:
cppyy.include("gmpxx.h")
cppyy.load_library('gmpxx')
except ImportError:
py.test.skip("gmpxx not installed")

assert cppyy.gbl.std.vector[cppyy.gbl.mpz_class].value_type

cppyy.cppdef("""\
namespace test15_templated_arrays_gmpxx::vector {
template <typename T>
using value_type = typename T::value_type;
}""")


g = cppyy.gbl
assert g.test15_templated_arrays_gmpxx.vector.value_type[g.std.vector[g.mpz_class]]


class TestMULTIDIMARRAYS:
def setup_class(cls):
Expand Down

0 comments on commit 76f6b30

Please sign in to comment.