Back to index

python3.2  3.2.2
Public Member Functions
ctypes.test.test_array_in_pointer.Test Class Reference

List of all members.

Public Member Functions

def test
def test_2

Detailed Description

Definition at line 19 of file test_array_in_pointer.py.


Member Function Documentation

Definition at line 20 of file test_array_in_pointer.py.

00020 
00021     def test(self):
00022         # create an array of 4 values
00023         val_array = (Value * 4)()
00024 
00025         # create a container, which holds a pointer to the pvalues array.
00026         c = Container()
00027         c.pvalues = val_array
00028 
00029         # memory contains 4 NUL bytes now, that's correct
00030         self.assertEqual("00-00-00-00", dump(val_array))
00031 
00032         # set the values of the array through the pointer:
00033         for i in range(4):
00034             c.pvalues[i].val = i + 1
00035 
00036         values = [c.pvalues[i].val for i in range(4)]
00037 
00038         # These are the expected results: here s the bug!
00039         self.assertEqual(
00040             (values, dump(val_array)),
00041             ([1, 2, 3, 4], "01-02-03-04")
00042         )

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 43 of file test_array_in_pointer.py.

00043 
00044     def test_2(self):
00045 
00046         val_array = (Value * 4)()
00047 
00048         # memory contains 4 NUL bytes now, that's correct
00049         self.assertEqual("00-00-00-00", dump(val_array))
00050 
00051         ptr = cast(val_array, POINTER(Value))
00052         # set the values of the array through the pointer:
00053         for i in range(4):
00054             ptr[i].val = i + 1
00055 
00056         values = [ptr[i].val for i in range(4)]
00057 
00058         # These are the expected results: here s the bug!
00059         self.assertEqual(
00060             (values, dump(val_array)),
00061             ([1, 2, 3, 4], "01-02-03-04")
00062         )

Here is the call graph for this function:


The documentation for this class was generated from the following file: