Skip to content

Commit 5e1ccdd

Browse files
flowergrassdpgeorge
authored andcommitted
tests/basics: Improve mpz test coverage.
1 parent 91359c8 commit 5e1ccdd

3 files changed

Lines changed: 10 additions & 0 deletions

File tree

tests/basics/int_big_rshift.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44

55
# result needs rounding up
66
print(-(1<<70) >> 80)
7+
print(-0xffffffffffffffff >> 32)

tests/basics/int_big_xor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
print((-a) ^ (1 << 200))
2020
print((-a) ^ a == 0)
2121
print(bool((-a) ^ a))
22+
print(-1 ^ 0xffffffffffffffff) # carry overflows to higher digit
2223

2324
# test + -
2425

tests/basics/int_mpz.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
# printing
88
print(x)
99
print(y)
10+
print('%#X' % (x - x)) # print prefix
11+
print('{:#,}'.format(x)) # print with commas
1012

1113
# addition
1214
print(x + 1)
@@ -67,6 +69,12 @@
6769
print(int("123456789012345678901234567890abcdef", 16))
6870
print(int("123456789012345678901234567890ABCDEF", 16))
6971

72+
# invalid characters in string
73+
try:
74+
print(int("123456789012345678901234567890abcdef"))
75+
except ValueError:
76+
print('ValueError');
77+
7078
# test constant integer with more than 255 chars
7179
x = 0x84ce72aa8699df436059f052ac51b6398d2511e49631bcb7e71f89c499b9ee425dfbc13a5f6d408471b054f2655617cbbaf7937b7c80cd8865cf02c8487d30d2b0fbd8b2c4e102e16d828374bbc47b93852f212d5043c3ea720f086178ff798cc4f63f787b9c2e419efa033e7644ea7936f54462dc21a6c4580725f7f0e7d1aaaaaaa
7280
print(x)

0 commit comments

Comments
 (0)