Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add tests for pop.
  • Loading branch information
ZeroIntensity committed Oct 19, 2024
commit 6a46733a8d3051a8d895df2d512799cae7ceeb9a
4 changes: 2 additions & 2 deletions Include/internal/pycore_dynarray.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,9 @@ _PyDynArray_LENGTH(_PyDynArray *array)
* This function cannot fail.
*/
static inline void *
_PyDynArray_PopTop(_PyDynArray *array, Py_ssize_t index)
_PyDynArray_PopTop(_PyDynArray *array)
{
return _PyDynArray_PopTop(array, _PyDynArray_LENGTH(array) - 1);
return _PyDynArray_Pop(array, _PyDynArray_LENGTH(array) - 1);
}

#ifdef __cplusplus
Expand Down
5 changes: 5 additions & 0 deletions Modules/_testinternalcapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2075,6 +2075,10 @@ test_dynarray_common(_PyDynArray *array)
APPEND(NULL);
}

assert(_PyDynArray_PopTop(array) == NULL);
APPEND((void *) 42);
assert(_PyDynArray_PopTop(array) == (void *) 42);

#undef APPEND

// Make sure that nothing got corrupted
Expand All @@ -2089,6 +2093,7 @@ test_dynarray_common(_PyDynArray *array)
Py_ssize_t index = _PyDynArray_DEFAULT_SIZE;
_PyDynArray_Set(array, index, (void *) 1);
assert(_PyDynArray_GET_ITEM(array, index) == (void *) 1);
assert(_PyDynArray_Pop(array, 0) == Py_True);
return 0;
}

Expand Down