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