Debian Codegraph @

pypy/module/cpyext/test/test_pymem.py

raw symbols SCIP
1 from pypy.module.cpyext.test.test_cpyext import AppTestCpythonExtensionBase
2
3
4 class AppTestPyMem(AppTestCpythonExtensionBase):
5 def test_pymem_alloc(self):
6 module = self.import_extension('foo', [
7 ("test", "METH_NOARGS",
8 """
9 int *a, *b;
10 a = PyMem_RawCalloc(4, 50);
11 if (a[49] != 0) {
12 PyErr_SetString(PyExc_ValueError, "1");
13 return NULL;
14 }
15 a[49] = 123456;
16 b = PyMem_RawRealloc(a, 2000);
17 b[499] = 789123;
18 PyMem_RawFree(b);
19
20 a = PyMem_Calloc(4, 50);
21 if (a[49] != 0) {
22 PyErr_SetString(PyExc_ValueError, "2");
23 return NULL;
24 }
25 a[49] = 123456;
26 b = PyMem_Realloc(a, 2000);
27 b[499] = 789123;
28 PyMem_Free(b);
29
30 Py_RETURN_NONE;
31 """),
32 ])
33 res = module.test()
34 assert res is None