From bbf68db1b99edffc24c93060dcbf5e8e3b5fe34f Mon Sep 17 00:00:00 2001 From: faze-geek Date: Fri, 1 Mar 2024 23:29:05 +0530 Subject: [PATCH] Test all binary operators --- tests/10_cmath.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/10_cmath.py b/tests/10_cmath.py index fd42034d..a850f0e3 100644 --- a/tests/10_cmath.py +++ b/tests/10_cmath.py @@ -1,6 +1,17 @@ from cmath import isclose, sqrt, nan, inf, nanj, infj, log import math +c1 = complex(3, 4) +c2 = complex(2, 4.5) + +assert c1 + 5 == complex(8,4) +assert c1 + c2 == complex(5, 8.5) +assert c1 - c2 == complex(1, -0.5) +assert c1*4 == complex(12, 16) +assert c1*c2 == complex(-12, 21.5) +assert c2/c1 == complex(0.96, 0.22) +assert isclose(c2**2, complex(-16.25, 17.99999999999999)) + assert 1+2j == complex(1, 2) == 2j+1 assert isclose(1+2j + 3+4j, 4+6j)