(size)
| 328 | |
| 329 | @pytest.mark.parametrize("size", [0, 1, 1000]) |
| 330 | def test_HostBuffer(size): |
| 331 | arr, buf = make_random_buffer(size) |
| 332 | assert arr.tobytes() == buf.to_pybytes() |
| 333 | hbuf = cuda.new_host_buffer(size) |
| 334 | np.frombuffer(hbuf, dtype=np.uint8)[:] = arr |
| 335 | assert hbuf.size == size |
| 336 | assert hbuf.is_cpu |
| 337 | assert arr.tobytes() == hbuf.to_pybytes() |
| 338 | for i in range(size): |
| 339 | assert hbuf[i] == arr[i] |
| 340 | for s in [ |
| 341 | slice(None), |
| 342 | slice(size//4, size//2), |
| 343 | ]: |
| 344 | assert hbuf[s].to_pybytes() == arr[s].tobytes() |
| 345 | |
| 346 | sbuf = hbuf.slice(size//4, size//2) |
| 347 | assert sbuf.parent == hbuf |
| 348 | |
| 349 | del hbuf |
| 350 | |
| 351 | with pytest.raises(TypeError, |
| 352 | match="Do not call HostBuffer's constructor directly"): |
| 353 | cuda.HostBuffer() |
| 354 | |
| 355 | |
| 356 | @pytest.mark.parametrize("size", [0, 1, 1000]) |
nothing calls this directly
no test coverage detected