FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add test for `PyBuffer.GetPointer` · pythonnet/pythonnet@48bb33a · GitHub

Repository navigation

Commit 48bb33a

Browse files
committed
Add test for PyBuffer.GetPointer
1 parent 72df9ae commit 48bb33a

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

‎src/embed_tests/TestPyBuffer.cs‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,22 @@ public void TestBufferRead()
5858
}
5959

6060
string result = new UTF8Encoding().GetString(managedArray);
61-
Assert.That(result == " " + bufferTestString.Substring(1), Is.True);
61+
Assert.That(result, Is.EqualTo($" {bufferTestString.Substring(1)}"));
62+
}
63+
64+
[Test]
65+
public void GetPointer()
66+
{
67+
// create 3D NumPy array
68+
int[] shape = [10, 10, 10];
69+
using PyObject ndArray = np.zeros(shape);
70+
71+
using PyBuffer buf = ndArray.GetBuffer(PyBUF.STRIDES);
72+
73+
// this throws System.ExecutionEngineException
74+
var ptr = buf.GetPointer([0, 0, 0]);
75+
76+
Assert.That(ptr, Is.Not.EqualTo(IntPtr.Zero));
6277
}
6378

6479
[Test]

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL