Skip to content

Commit

Permalink
add additional test for int8_t/uint8_t array global vars (following #154
Browse files Browse the repository at this point in the history
)
  • Loading branch information
wlav committed Nov 14, 2023
1 parent 75dda50 commit 33c1f91
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/datatypes.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1037,3 +1037,10 @@ MULTIDIM_ARRAYS_NEW2D(long long, llong)
MULTIDIM_ARRAYS_NEW2D(unsigned long long, ullong)
MULTIDIM_ARRAYS_NEW2D(float, float)
MULTIDIM_ARRAYS_NEW2D(double, double)


//===========================================================================
namespace Int8_Uint8_Arrays {
int8_t test[6] = {-0x12, -0x34, -0x56, -0x78};
uint8_t utest[6] = { 0x12, 0x34, 0x56, 0x78};
}
7 changes: 7 additions & 0 deletions test/datatypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -855,4 +855,11 @@ struct DataHolder {

} // namespace MultiDimArrays


//= int8_t/uint8_t arrays ===================================================
namespace Int8_Uint8_Arrays {
extern int8_t test[6];
extern uint8_t utest[6];
}

#endif // !CPPYY_TEST_DATATYPES_H
12 changes: 12 additions & 0 deletions test/test_datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2343,3 +2343,15 @@ def test49_addressof_method(self):

assert cppyy.addressof(cppyy.gbl.std.vector[int].at.__overload__(':any:', False))
assert cppyy.addressof(cppyy.gbl.std.vector[int].at.__overload__(':any:', True))

def test50_int8_uint8_global_arrays(self):
"""Access to int8_t/uint8_t arrays that are global variables"""

import cppyy

ns = cppyy.gbl.Int8_Uint8_Arrays

assert [ns.test[i] for i in range(6)] == [-0x12, -0x34, -0x56, -0x78, 0x0, 0x0]
assert [ns.utest[i] for i in range(6)] == [ 0x12, 0x34, 0x56, 0x78, 0x0, 0x0]


0 comments on commit 33c1f91

Please sign in to comment.