From a90a5cba08fdf6c0ceb95101c275108a152a3aed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:35:37 +0200 Subject: Merging upstream version 127.0. Signed-off-by: Daniel Baumann --- .../arithmetic/tests/bindings/test_arithmetic.py | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 toolkit/components/uniffi-fixtures/arithmetic/tests/bindings/test_arithmetic.py (limited to 'toolkit/components/uniffi-fixtures/arithmetic/tests/bindings/test_arithmetic.py') diff --git a/toolkit/components/uniffi-fixtures/arithmetic/tests/bindings/test_arithmetic.py b/toolkit/components/uniffi-fixtures/arithmetic/tests/bindings/test_arithmetic.py new file mode 100644 index 0000000000..e1b4f71277 --- /dev/null +++ b/toolkit/components/uniffi-fixtures/arithmetic/tests/bindings/test_arithmetic.py @@ -0,0 +1,37 @@ +from arithmetic import InternalError, add, div, equal, sub + +try: + add(18446744073709551615, 1) + assert not ("Should have thrown a IntegerOverflow exception!") +except ArithmeticError.IntegerOverflow: + # It's okay! + pass + +assert add(2, 4) == 6 +assert add(4, 8) == 12 + +try: + sub(0, 1) + assert not ("Should have thrown a IntegerOverflow exception!") +except ArithmeticError.IntegerOverflow: + # It's okay! + pass + +assert sub(4, 2) == 2 +assert sub(8, 4) == 4 + +assert div(8, 4) == 2 + +try: + div(8, 0) +except InternalError: + # It's okay! + pass +else: + assert not ("Should have panicked when dividing by zero") + +assert equal(2, 2) +assert equal(4, 4) + +assert not equal(2, 4) +assert not equal(4, 8) -- cgit v1.2.3