def test_invertsign(): q1 = Qualean(random.choice([-1, 0, 1])) if q1.get_number() < 0: assert (q1.__invertsign__() > 0) == True, "invertsign not working" elif q1.get_number() > 0: assert (q1.__invertsign__() < 0) == True, "invertsign not working" else: assert (q1.__invertsign__() == 0) == True, "invertsign not working"
def test_qualean_lt(): q1, q2 = Qualean(1), Qualean(0) if q1.number > 0: q1 = q1.__invertsign__() assert q1 < q2
def test_qualean_gt(): q1, q2 = Qualean(1), Qualean(0) if q1.number < 0: q1 = q1.__invertsign__() assert q1 > q2
def test_qualean_le(): q1, q2, q3 = Qualean(1), Qualean(0), Qualean(0) if q1.number > 0: q1 = q1.__invertsign__() assert q1 <= q2 assert q2 <= q3
def test_qualean_ge(): q1, q2, q3 = Qualean(1), Qualean(0), Qualean(0) if q1.number < 0: q1 = q1.__invertsign__() assert q1 >= q2 assert q2 >= q3
def test_qualean_sqrt(): decimal.getcontext().prec = 10 sign = lambda x : copysign(1.0, x) q = Qualean(-1) if q.number < 0: q = q.__invertsign__() assert q.__sqrt__() == Decimal(q.number).sqrt()
def test_function_invertsign(): q1 = Qualean(random.choice(states)) if q1 != 0: assert q1.__invertsign__() == -q1.q else: assert q1==0