Skip to content

Commit

Permalink
new test case
Browse files Browse the repository at this point in the history
  • Loading branch information
Bchass committed Jun 27, 2024
1 parent 3003d5c commit 183ca80
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tinynumpy/tests/test_tinynumpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,30 @@ def test_multiple_dimensions():
assert b.flags['F_CONTIGUOUS'] == True


def test_ndarray_int_conversion():
# Test case 1: Array with size 1
a = tnp.array([42])
assert int(a) == 42

# Test case 2: Array with size > 1
b = tnp.array([1, 2, 3])
try:
int(b)
except TypeError as e:
assert str(e) == 'Only length-1 arrays can be converted to scalar'
else:
assert False, "Expected TypeError not raised"

# edge scenarios
c = tnp.array([], dtype='int32')
try:
int(c)
except TypeError as e:
assert str(e) == 'Only length-1 arrays can be converted to scalar'
else:
assert False, "Expected TypeError not raised"


def test_repr():
for dtype in ['float32', 'float64', 'int32', 'int64']:
for data in [
Expand Down

0 comments on commit 183ca80

Please sign in to comment.