Пример #1
0
    def test_ordering(self):
        inter = Interval(0, 15)
        var1 = Variable(inter)

        var2 = Variable(inter.move(5))
        assert var1 < var2
        assert var1 != var2

        var2 = Variable(inter.move(-5))
        assert var1 > var2
        assert var1 != var2

        var2 = Variable(Interval(0, 5))
        assert var1 > var2
        assert var1 != var2

        var2 = Variable(Interval(0, 20))
        assert var1 < var2
        assert var1 != var2

        var2 = Variable(Interval(0, 15))
        assert var1 == var2
        assert not var1 < var2
        assert not var1 > var2

        var2 = Variable(None)
        assert var1 != var2
        assert var1 > var2
        assert not var1 < var2

        var2 = Variable()
        assert var1 != var2
        assert var1 > var2
Пример #2
0
    def test_move(self):
        inter = Interval(0, 10)
        inter = inter.move(5)
        assert isinstance(inter, Interval)
        assert inter.start == 5
        assert inter.end == 15

        inter = inter.move(-5)
        assert inter.start == 0
        assert inter.end == 10
Пример #3
0
    def test_hash(self):
        inter = Interval(2, 20)
        assert hash(inter) == (2 ^ 20)
        x = [1, 7, 1, 23, 1, 7, 1, 23, 1, 7, 1, 23, 1, 7]

        for m in x:
            inter = inter.move(m)
            assert hash(inter) == (2 ^ 20)

        inter = Interval(float("-inf"), float("inf"))
        assert hash(inter) == hash(float("-inf")) ^ hash(float("inf"))
Пример #4
0
    def test_ordering(self):
        var1 = Interval(0, 15)

        var2 = var1.move(5)
        assert var1 < var2
        assert var1 != var2

        var2 = var1.move(-5)
        assert var1 > var2
        assert var1 != var2

        var2 = Interval(0, 5)
        assert var1 > var2
        assert var1 != var2

        var2 = Interval(0, 20)
        assert var1 < var2
        assert var1 != var2

        var2 = Interval(0, 15)
        assert var1 == var2
        assert tuple(var1) == tuple(var2)
        assert not var1 < var2
        assert not var1 > var2