From 9c4c3e737db00eb0003bbc252484c3af2ce1a40d Mon Sep 17 00:00:00 2001
From: Yichao Yu <yyc1992@gmail.com>
Date: Mon, 23 Jun 2014 09:51:54 +0800
Subject: [PATCH] more test for MemoryObject.get_host_array

---
 test/test_wrapper.py | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/test/test_wrapper.py b/test/test_wrapper.py
index 8f86ff17..ba6c90f1 100644
--- a/test/test_wrapper.py
+++ b/test/test_wrapper.py
@@ -707,6 +707,23 @@ def test_buffer_get_host_array(ctx_factory):
             host_buf.__array_interface__['data'][0])
     assert host_buf2.base is buf
 
+    try:
+        buf = cl.Buffer(ctx, mf.READ_WRITE | mf.COPY_HOST_PTR, size=100)
+        host_buf2 = buf.get_host_array(25, np.float32)
+        assert False, ("MemoryObject.get_host_array should not accept buffer "
+                       "without USE_HOST_PTR")
+    except cl.LogicError:
+        pass
+
+    try:
+        host_buf = np.random.rand(25).astype(np.float32)
+        buf = cl.Buffer(ctx, mf.READ_WRITE | mf.COPY_HOST_PTR, hostbuf=host_buf)
+        host_buf2 = buf.get_host_array(25, np.float32)
+        assert False, ("MemoryObject.get_host_array should not accept buffer "
+                       "without USE_HOST_PTR")
+    except cl.LogicError:
+        pass
+
 if __name__ == "__main__":
     # make sure that import failures get reported, instead of skipping the tests.
     import pyopencl  # noqa
-- 
GitLab