(self)
| 107 | self.assertTrue(sub_buf.is_initialized()) |
| 108 | |
| 109 | def test_subbuffer_copy_in_out(self): |
| 110 | sub_buf = self.buf.view(3, dtypes.uint8, offset=3).ensure_allocated() # [3:6] |
| 111 | data_out_sub = bytearray([0]*3) |
| 112 | sub_buf.copyout(memoryview(data_out_sub)) |
| 113 | assert data_out_sub == bytearray(range(3, 6)) |
| 114 | sub_buf.copyin(memoryview(bytearray(range(3)))) |
| 115 | assert sub_buf.as_memoryview().tolist() == list(range(3)) |
| 116 | assert self.buf.as_memoryview().tolist()[3:6] == list(range(3)) |
| 117 | sub_buf.copyout(memoryview(data_out_sub)) |
| 118 | assert data_out_sub == bytearray(range(3)) |
| 119 | data_out_base = bytearray([0]*10) |
| 120 | self.buf.copyout(memoryview(data_out_base)) |
| 121 | assert data_out_base[0:3] == bytearray(range(0, 3)) |
| 122 | assert data_out_base[3:6] == data_out_sub |
| 123 | assert data_out_base[6:10] == bytearray(range(6, 10)) |
| 124 | |
| 125 | def test_subbuffer_copy_in_out_view_of_view(self): |
| 126 | view1 = self.buf.view(7, dtypes.uint8, offset=2).ensure_allocated() # [2:9] |
nothing calls this directly
no test coverage detected