Skip to content

Commit 7d338cc

Browse files
committed
Add a few more tests
1 parent c67985d commit 7d338cc

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

‎Modules/_testlimitedcapi/object.c‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,25 @@ test_min_max_abs_macros(PyObject *self, PyObject *Py_UNUSED(ignored))
262262
assert(Py_MAX(x, Py_MIN(y, z)) == 5);
263263
assert(Py_ABS(Py_ABS(z)) == 11);
264264

265+
// A few more tests
266+
assert(Py_MIN(2, Py_MIN(6, 12)) == 2);
267+
assert(Py_MAX(2, Py_MAX(6, 12)) == 12);
268+
assert(Py_MIN(2, Py_MAX(6, 12)) == 2);
269+
assert(Py_MAX(2, Py_MIN(6, 12)) == 6);
270+
assert(Py_MIN(Py_MIN(2, 6), 12) == 2);
271+
assert(Py_MAX(Py_MAX(2, 6), 12) == 12);
272+
assert(Py_MIN(Py_MAX(2, 6), 12) == 6);
273+
assert(Py_MAX(Py_MIN(2, 6), 12) == 12);
274+
assert(Py_ABS(Py_ABS(12)) == 12);
275+
assert(Py_ABS(Py_ABS(12)) == 12);
276+
277+
// Integer limits
278+
assert(Py_MIN(123, INT_MIN) == INT_MIN);
279+
assert(Py_MAX(123, INT_MAX) == INT_MAX);
280+
assert(Py_ABS(INT_MAX) == INT_MAX);
281+
// Do not tests Py_ABS(INT_MIN), since the behavior is documented.
282+
// This limitation is documented in Py_ABS() documentation.
283+
265284
#if ((defined(__GNUC__) || defined(__clang__)) \
266285
&& defined(_Py_TYPEOF) && !defined(__cplusplus))
267286
// Check that arguments are only evaluated once

0 commit comments

Comments
 (0)