Beispiel #1
0
def test_functions_for_zero():
    assert session3.float_equality_testing(
        0.0, 0.0), 'How can zero be not equal to zero?'
    assert session3.manual_truncation_function(
        0.0) == 0, 'Tuncation of 0 should be zero'
    assert session3.manual_rounding_function(
        0.0) == 0, 'Zero can only be rounded off to zero'
Beispiel #2
0
def test_float_equality_testing():
    for _ in range(10000):
        scale = random.randint(1, 1000000)
        a = random.uniform(-1.5, 1.6)
        a, b = a * scale, a * scale - a / scale
        assert session3.float_equality_testing(a, b) == math.isclose(
            a, b, rel_tol=1e-12, abs_tol=1e-05
        ), 'Aap jis number se sampark karna chahte hai, woh is samay uplabdh nahi hai, kripya thodi der baad prayas karein. The numbers you are trying to check right now are not equal, please try again later'