Пример #1
0
def test_interval_int_comparison_methods():
    iv = Interval(0, 10)

    assert iv.gt(-5)
    assert iv.ge(-5)
    assert not iv.lt(-5)
    assert not iv.le(-5)

    assert not iv.gt(0)
    assert iv.ge(0)
    assert not iv.lt(0)
    assert not iv.le(0)

    assert not iv.gt(5)
    assert not iv.ge(5)
    assert not iv.lt(5)
    assert not iv.le(5)

    assert not iv.gt(10)
    assert not iv.ge(10)
    assert iv.lt(10)
    assert iv.le(10)

    assert not iv.gt(15)
    assert not iv.ge(15)
    assert iv.lt(15)
    assert iv.le(15)
Пример #2
0
def test_interval_null_interval_comparison_methods():
    """
    Test comparisons with other Intervals using gt(), ge(), lt() and
    le()
    """
    iv0 = Interval(0, 10)
    ivn = Interval(0, 0)

    with pytest.raises(ValueError):
        iv0.gt(ivn)

    with pytest.raises(ValueError):
        ivn.gt(iv0)

    with pytest.raises(ValueError):
        iv0.ge(ivn)

    with pytest.raises(ValueError):
        ivn.ge(iv0)

    with pytest.raises(ValueError):
        iv0.lt(ivn)

    with pytest.raises(ValueError):
        ivn.lt(iv0)

    with pytest.raises(ValueError):
        iv0.le(ivn)

    with pytest.raises(ValueError):
        ivn.le(iv0)
Пример #3
0
def test_interval_int_comparison_methods():
    iv = Interval(0, 10)

    assert iv.gt(-5)
    assert iv.ge(-5)
    assert not iv.lt(-5)
    assert not iv.le(-5)

    assert not iv.gt(0)
    assert iv.ge(0)
    assert not iv.lt(0)
    assert not iv.le(0)

    assert not iv.gt(5)
    assert not iv.ge(5)
    assert not iv.lt(5)
    assert not iv.le(5)

    assert not iv.gt(10)
    assert not iv.ge(10)
    assert iv.lt(10)
    assert iv.le(10)

    assert not iv.gt(15)
    assert not iv.ge(15)
    assert iv.lt(15)
    assert iv.le(15)
Пример #4
0
def test_interval_int_comparison_methods():
    """
    Test comparisons with integers using gt(), ge(), lt() and le()
    """
    iv = Interval(0, 10)

    assert iv.gt(-5)
    assert iv.ge(-5)
    assert not iv.lt(-5)
    assert not iv.le(-5)

    assert not iv.gt(0)
    assert iv.ge(0)
    assert not iv.lt(0)
    assert not iv.le(0)

    assert not iv.gt(5)
    assert not iv.ge(5)
    assert not iv.lt(5)
    assert not iv.le(5)

    assert not iv.gt(10)
    assert not iv.ge(10)
    assert iv.lt(10)
    assert iv.le(10)

    assert not iv.gt(15)
    assert not iv.ge(15)
    assert iv.lt(15)
    assert iv.le(15)
Пример #5
0
def test_interval_null_interval_comparison_methods():
    """
    Test comparisons with other Intervals using gt(), ge(), lt() and
    le()
    """
    iv0 = Interval(0, 10)
    ivn = Interval(0, 0)
    
    with pytest.raises(ValueError):
        iv0.gt(ivn)
    
    with pytest.raises(ValueError):
        ivn.gt(iv0)

    with pytest.raises(ValueError):
        iv0.ge(ivn)
    
    with pytest.raises(ValueError):
        ivn.ge(iv0)

    with pytest.raises(ValueError):
        iv0.lt(ivn)
    
    with pytest.raises(ValueError):
        ivn.lt(iv0)

    with pytest.raises(ValueError):
        iv0.le(ivn)
    
    with pytest.raises(ValueError):
        ivn.le(iv0)
Пример #6
0
def test_interval_int_comparison_methods():
    """
    Test comparisons with integers using gt(), ge(), lt() and le()
    """
    iv = Interval(0, 10)

    assert iv.gt(-5)
    assert iv.ge(-5)
    assert not iv.lt(-5)
    assert not iv.le(-5)

    assert not iv.gt(0)
    assert iv.ge(0)
    assert not iv.lt(0)
    assert not iv.le(0)

    assert not iv.gt(5)
    assert not iv.ge(5)
    assert not iv.lt(5)
    assert not iv.le(5)

    assert not iv.gt(10)
    assert not iv.ge(10)
    assert iv.lt(10)
    assert iv.le(10)

    assert not iv.gt(15)
    assert not iv.ge(15)
    assert iv.lt(15)
    assert iv.le(15)
Пример #7
0
def test_interval_interval_comparison_methods():
    """
    Test comparisons with other Intervals using gt(), ge(), lt() and
    le()
    """
    iv0 = Interval(0, 10)
    iv1 = Interval(-10, -5)
    iv2 = Interval(-10, 0)
    iv3 = Interval(-10, 5)
    iv4 = Interval(-10, 10)
    iv5 = Interval(-10, 20)
    iv6 = Interval(0, 20)
    iv7 = Interval(5, 20)
    iv8 = Interval(10, 20)
    iv9 = Interval(15, 20)

    assert not iv0.gt(iv0)
    assert iv0.gt(iv1)
    assert iv0.gt(iv2)
    assert not iv0.gt(iv3)
    assert not iv0.gt(iv4)
    assert not iv0.gt(iv5)
    assert not iv0.gt(iv6)
    assert not iv0.gt(iv7)
    assert not iv0.gt(iv8)
    assert not iv0.gt(iv9)

    assert iv0.ge(iv0)
    assert iv0.ge(iv1)
    assert iv0.ge(iv2)
    assert iv0.ge(iv3)
    assert iv0.ge(iv4)
    assert iv0.ge(iv5)
    assert iv0.ge(iv6)
    assert not iv0.ge(iv7)
    assert not iv0.ge(iv8)
    assert not iv0.ge(iv9)

    assert not iv0.lt(iv0)
    assert not iv0.lt(iv1)
    assert not iv0.lt(iv2)
    assert not iv0.lt(iv3)
    assert not iv0.lt(iv4)
    assert not iv0.lt(iv5)
    assert not iv0.lt(iv6)
    assert not iv0.lt(iv7)
    assert iv0.lt(iv8)
    assert iv0.lt(iv9)

    assert iv0.le(iv0)
    assert not iv0.le(iv1)
    assert not iv0.le(iv2)
    assert not iv0.le(iv3)
    assert iv0.le(iv4)
    assert iv0.le(iv5)
    assert iv0.le(iv6)
    assert iv0.le(iv7)
    assert iv0.le(iv8)
    assert iv0.le(iv9)
Пример #8
0
def test_interval_interval_comparison_methods():
    """
    Test comparisons with other Intervals using gt(), ge(), lt() and
    le()
    """
    iv0 = Interval(0, 10)
    iv1 = Interval(-10, -5)
    iv2 = Interval(-10, 0)
    iv3 = Interval(-10, 5)
    iv4 = Interval(-10, 10)
    iv5 = Interval(-10, 20)
    iv6 = Interval(0, 20)
    iv7 = Interval(5, 20)
    iv8 = Interval(10, 20)
    iv9 = Interval(15, 20)

    assert not iv0.gt(iv0)
    assert iv0.gt(iv1)
    assert iv0.gt(iv2)
    assert not iv0.gt(iv3)
    assert not iv0.gt(iv4)
    assert not iv0.gt(iv5)
    assert not iv0.gt(iv6)
    assert not iv0.gt(iv7)
    assert not iv0.gt(iv8)
    assert not iv0.gt(iv9)

    assert iv0.ge(iv0)
    assert iv0.ge(iv1)
    assert iv0.ge(iv2)
    assert iv0.ge(iv3)
    assert iv0.ge(iv4)
    assert iv0.ge(iv5)
    assert iv0.ge(iv6)
    assert not iv0.ge(iv7)
    assert not iv0.ge(iv8)
    assert not iv0.ge(iv9)

    assert not iv0.lt(iv0)
    assert not iv0.lt(iv1)
    assert not iv0.lt(iv2)
    assert not iv0.lt(iv3)
    assert not iv0.lt(iv4)
    assert not iv0.lt(iv5)
    assert not iv0.lt(iv6)
    assert not iv0.lt(iv7)
    assert iv0.lt(iv8)
    assert iv0.lt(iv9)

    assert iv0.le(iv0)
    assert not iv0.le(iv1)
    assert not iv0.le(iv2)
    assert not iv0.le(iv3)
    assert iv0.le(iv4)
    assert iv0.le(iv5)
    assert iv0.le(iv6)
    assert iv0.le(iv7)
    assert iv0.le(iv8)
    assert iv0.le(iv9)