Exemple #1
0
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_decimal_sqrt_check():
    q1 = Qualean(1)
    Decimal_Test=False
    print(Decimal_Test)
    if q1.q >= 0:
        with decimal.localcontext() as ctx:
            ctx.prec = 10
            ctx.rounding = decimal.ROUND_HALF_EVEN
            if  q1.__sqrt__() == Decimal(str(q1)).sqrt(context=ctx):
                Decimal_Test=True
                pass
            else:
                pass
    else:
        Decimal_Test= True
    print(Decimal_Test)
    assert Decimal_Test == True, "Check your the function"
def test_sqrt():
    q = Qualean(num)
    # print(q.__sqrt__() ,Decimal(q.__float__()))
    assert q.__sqrt__() == Decimal(math.sqrt(q))