Пример #1
0
def test_lt():
    q1 = qualean(1)
    q2 = qualean(-1)
    x1 = q1.qual
    x2 = q2.qual
    if x1 < x2:
        assert q1 < q2, "less than not working"
    else:
        assert q2 < q1, "less than not working"
Пример #2
0
def test_ge():
    q1 = qualean(1)
    q2 = qualean(-1)
    x1 = q1.qual
    x2 = q2.qual
    if x1 >= x2:
        assert q1 >= q2, "greater than equal to not working"
    else:
        assert q2 >= q1, "greater than equal to not working"
Пример #3
0
def test_n_times_addition():
    q = qualean(1)
    x = 0
    for i in range(100):
        x = q + x
    y = q * 100
    assert x == y, "q + q + q ... 100 times = 100 * q"
Пример #4
0
def test_one_million_qs_mul():
    x = 1
    for i in range(1000000):
        x = qualean(random.randint(-1, 1)) * x
    assert math.isclose(x, 0), "not nearing to 0"
Пример #5
0
def test_one_million_qs_add():
    x = 0
    for i in range(1000000):
        x = qualean(random.randint(-1, 1)) + x
    assert math.isclose(x, 0, rel_tol=1), str(x) + " not nearing to 0"
Пример #6
0
def test_sqrt_func():
    q = qualean(1)
    if float(q) < 0:
        ~q
    assert q.__sqrt__() == Decimal(
        str(q)).sqrt(), "q.__sqrt__() = Decimal(q).sqrt"
Пример #7
0
def test_float_conversion():
    q = qualean(1)
    x = float(q)
    assert type(x) == type(float()), "unable to convert to float"
Пример #8
0
def test_or_False():
    q1 = qualean(0)
    q2 = 0
    assert (q2 or bool(q1)) == False, "and False not working"
Пример #9
0
def test_and_False():
    q1 = qualean(0)
    q2 = 0
    assert (bool(q1) and q2) == False, "and False not working"
Пример #10
0
def test_eq():
    q = qualean(1)
    assert q == q, "equality function not working"
Пример #11
0
def test_srt():
    r = qualean(1)
    num = r.qual
    assert r.__str__(
    ) == f'{num}', 'The print of the Qualean object does not meet expectations'
Пример #12
0
def test_repr():
    r = qualean(1)
    num = r.qual
    assert r.__repr__(
    ) == f'{num}', 'The representation of the Qualean object does not meet expectations'
Пример #13
0
def test_invert():
    q1 = qualean(1)
    y = q1.qual
    ~q1
    x = q1.qual
    assert x + y == 0, "Invert not working"
Пример #14
0
def test_bool_False():
    q1 = qualean(0)
    assert bool(q1) == False, "bool False operator not working"
Пример #15
0
def test_qualean_values():
    with pytest.raises(ValueError) as e_info:
        r = qualean(3)
Пример #16
0
def test_bool_True():
    q1 = qualean(1)
    assert bool(q1) == True, "bool True operator not working"
Пример #17
0
def test_bankers_rounding():
    q = qualean(1)
    x = str(q.qual)
    x = x.split('.')[1]
    assert len(x) == 10, x + " 10 decimal places not present"
Пример #18
0
def test_and_True():
    q1 = qualean(1)
    q2 = qualean(-1)
    assert (bool(q1) and bool(q2)) == True, "and True not working"
Пример #19
0
def test_or_True():
    q1 = qualean(1)
    q2 = 0
    assert (bool(q1) or q2) == True, "or True not working"