def testReadByte(self): data = Marshal.AllocHGlobal(1) Marshal.WriteByte(data, 0) self.assertEquals(CPyMarshal.ReadByte(data), 0, "wrong") Marshal.WriteByte(data, 255) self.assertEquals(CPyMarshal.ReadByte(data), 255, "wrong") Marshal.FreeHGlobal(data)
def ptrFromByteArray(self, bytes): testData = Marshal.AllocHGlobal(bytes.Length + 1) Marshal.Copy(bytes, 0, testData, bytes.Length) Marshal.WriteByte(OffsetPtr(testData, bytes.Length), 0) return testData